Scott,
You helped me on this and in the past a lot. I really appreciate it. I am
completely lost from now on. The following code does not fail but does not
update the table either. SqlClientCommandBuilder is not recognized in my
environment.
I copy-paste the code I have up to now. What it does for the moment, once
user clicked Button1, it goes to this propriatery database and fills dataset
Ds and displays it on the screen and then calls ELiveConnSQL to import Ds
into TableDest which has the same structure as sqlStr select string. Can you
complete ELiveConnSQL function?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim sqlStr As String
sqlStr = "SELECT pate_id as PtID,date as ADate, time as ATime, name
as PtName FROM TableSrc WHERE date ='20050222' AND Loc='0A1'"
ELiveConn(sqlStr)
End Sub
Private Sub ELiveConn(ByVal sqlStr As String)
Dim rowNum As Integer
Dim colNum As Integer
Dim retValue As String
Dim strConn As String = "Driver={Microsoft Visual FoxPro
Driver};SourceType=DBF;SourceDB=\\TServer\Test;Exclusive=No" ' working,
Dim Conn As OdbcConnection = New OdbcConnection(strConn)
Try
Conn.Open()
Catch e As System.Exception
Response.Write("Connection has failed: " & strConn)
Exit Sub
End Try
Dim Da As New OdbcDataAdapter
Dim Ds As New DataSet
Dim cmdSelect As New OdbcCommand
Dim i As Integer
Dim Dr As DataRow
Dim Dt As DataTable
' populate dataAdapter and dataset
cmdSelect = Conn.CreateCommand
cmdSelect.CommandText = sqlStr
Da.SelectCommand = cmdSelect
Da.Fill(Ds, "ReturnedRows")
rowNum = Ds.Tables(0).Rows.Count()
colNum = Ds.Tables(0).Columns.Count()
Response.Write("Row Count: " & rowNum & " Column Count: " & colNum)
' populate datagrid
DataGrid1.DataSource = Ds
DataGrid1.DataMember = "ReturnedRows"
DataGrid1.DataBind()
retValue = ELiveConnSQL(Me.SqlConnection1.ConnectionString, sqlStr,
Ds)
' close connection
Da.Dispose()
Conn.Close()
End Sub
Private Function ELiveConnSQL(ByVal myConnStr As String, ByVal mySQLStr
As String, ByVal myDs As DataSet) As String
Dim myConn As SqlConnection
Dim myDA As SqlDataAdapter
Dim retValue As String
myConn = New SqlConnection(myConnStr)
myDA = New SqlDataAdapter(mySQLStr, myConn)
'myDA.InsertCommand.CommandText = "insert ??"
'Dim cb As New SqlClientCommandBuilder(myDA)
myDA.Update(myDs) 'Fill the DataSet with the rows returned.
retValue = "SUCCESS"
myDA.Dispose() 'Dispose of the DataAdapter.
myConn.Close() 'Close the connection.
Return retValue
End Function
Thanks you very much.
Jim.