this is code but this use 2 oledbdataadapter?
acroding u say we can just u onw oledbdataadapter can u show me how ?
Dim mySelectQuery As String = "SELECT column1 FROM table1"
Dim mycommand1 As System.Data.OleDb.OleDbDataAdapter
Dim mycommand2 As System.Data.OleDb.OleDbDataAdapter
Dim ds As New DataSet
'Dim ds2 As New DataSet
Dim i As Integer
Dim myConnection As New OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=C:\SA20051118.xls; " & _
"Extended Properties=Excel 8.0;")
'Dim myCommand As New OleDbCommand("select * from [Sheet1$]", myConnection)
mycommand1 = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", myConnection)
Dim cmd As System.Data.OleDb.OleDbCommand
Dim param As System.Data.OleDb.OleDbParameter
Dim cin As New OleDbConnection("Provider=SQLOLEDB;Data Source=taufan;Initial Catalog=RJats;Integrated Security=SSPI;")
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
mycommand2 = New System.Data.OleDb.OleDbDataAdapter("select * from sa", cin)
Try
cmd = New System.Data.OleDb.OleDbCommand("insert into sa (SecurityCode,Qty,TotalAmt)values(@SecurityCode,@Qty,@TotalAmt)", cin)
cmd.Parameters.Add("@CustomerCode", SqlDbType.NVarChar, 12, "CustomerCode")
cmd.Parameters.Add("@SecurityCode", SqlDbType.NVarChar, 12, "SecurityCode")
cmd.Parameters.Add("@Qty", SqlDbType.NVarChar, 12, "Qty")
cmd.Parameters.Add("@TotalAmt", SqlDbType.NVarChar, 12, "TotalAmt")
mycommand2.InsertCommand = cmd
mycommand1.Fill(ds, 0)
mycommand2.Fill(ds, 1)
For i = 0 To ds.Tables(0).Rows.Count - 1
Dim newrow As DataRow = ds.Tables(1).NewRow()
newrow(0) = ds.Tables(0).Rows(i)(0)
newrow(1) = ds.Tables(0).Rows(i)(1)
newrow(2) = ds.Tables(0).Rows(i)(2)
newrow(3) = ds.Tables(0).Rows(i)(3)
ds.Tables(1).Rows.Add(newrow)
mycommand2.Update(ds.Tables(1))
Next i
Me.Cursor = System.Windows.Forms.Cursors.Default
Catch ex As OleDbException
MsgBox(ex.Message, MsgBoxStyle.Information, Me.Text)
End Try
Enter your message below
Sign in or Join us (it's free).