Yes, but i want to make it like datafill.transpose (i know, that it
don't exists) or something like that.
But in my full aplication there will be about 50-100 columns.
I thought, that there is a way to transpose data in dataset and fill it
into other table (TableB). I created TableB with correct columns and i'm
trying to fill it. It's not qa problem, that Table or dataset will have
more columns then other one. How only fill rows?
My code:
Public Sub SQL_Wpis()
Dim sSQL As String
sSQL = "SELECT * FROM KanaSecRep"
Dim objConn As New SqlConnection(sConnection)
Dim objDataAdapter As New SqlDataAdapter(sSQL, objConn)
Dim objDS As New DataSet("KA_STAN")
Dim objInsertCommand As New SqlCommand
Dim sInsertSQL As String
Dim objParam As SqlParameter
If objConn.State = ConnectionState.Open Then
Try
objDataAdapter.MissingSchemaAction() = _
MissingSchemaAction.AddWithKey
objDataAdapter.Fill(objDS, "KanaSecRep")
objConn.Close()
Dim objTable As DataTable
objTable = objDS.Tables("KanaSecRep")
Dim drRows As DataRowCollection
Dim objCurrentRow As DataRow
drRows = objTable.Rows
objConn.Open()
objDataAdapter.Update(objDS, "KanaSecRep")
Dim sNowywpisSQLpiv = "INSERT INTO KanaSecRep" & "(Nazwastacji, DC, MS,
Data, AuditBaseObjects, ShutdownWithoutLogon" & " VALUES ('" &
strKomputer & "','" & IsDC(strKomputer) & "','" & IsMS(strKomputer) &
"','" & DateTime.Now & "','" & AuditBaseObjects(strKomputer) & "','" &
ShutdownWithoutLogon(strKomputer) & "'
Dim objNewCmd As New SqlCommand(sNowywpisSQLpiv, objConn)
objNewCmd.ExecuteNonQuery()
Catch myException As System.Exception
Console.WriteLine(myException.Message)
End Try
Console.Write("Koniec")
End If
End Sub
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!