none
odbc RRS feed

答案

  • 你好!
         可以参考这个例子:
    1. Public Function CreateCmdsAndUpdate(ByVal dataSet As DataSet, ByVal connectionString As String, ByVal queryString As String) As DataSet
    2.     Using connection As New OleDbConnection(connectionString)
    3.         Dim adapter As New OleDbDataAdapter()
    4.         adapter.SelectCommand = New OleDbCommand(queryString, connection)
    5.         Dim builder As New OleDbCommandBuilder(adapter)
    6.        
    7.         connection.Open()
    8.        
    9.         Dim customers As New DataSet()
    10.         adapter.Fill(customers)
    11.        
    12.         'code to modify data in dataset here
    13.        
    14.         adapter.Update(customers)
    15.        
    16.         Return customers
    17.     End Using
    18. End Function

    周雪峰
    2009年8月14日 12:50
    版主

全部回复

  • 你好!
         可以参考这个例子:
    1. Public Function CreateCmdsAndUpdate(ByVal dataSet As DataSet, ByVal connectionString As String, ByVal queryString As String) As DataSet
    2.     Using connection As New OleDbConnection(connectionString)
    3.         Dim adapter As New OleDbDataAdapter()
    4.         adapter.SelectCommand = New OleDbCommand(queryString, connection)
    5.         Dim builder As New OleDbCommandBuilder(adapter)
    6.        
    7.         connection.Open()
    8.        
    9.         Dim customers As New DataSet()
    10.         adapter.Fill(customers)
    11.        
    12.         'code to modify data in dataset here
    13.        
    14.         adapter.Update(customers)
    15.        
    16.         Return customers
    17.     End Using
    18. End Function

    周雪峰
    2009年8月14日 12:50
    版主
  • Dim odbcDbConnetion1 As Microsoft.Data.OdbcConnection  

    Dim strConnect As Sting=”Driver={SQL Server};Server=服务器名;Uid=sa;pwd=;Database= 数据库名;” 

    odbcDbConnetion1=New Microsoft.Data.OdbcConnection(strConnect) 

    http://hi.baidu.com/2009ajun
    2009年8月14日 22:40