問題
使用 DataSet.Load載入DataReader所讀出的值
解決方法
'Define connection Dim con As SqlConnection = new SqlConnection("connection string in here") Dim strSQL As String= "Select * from table1" 'Define command Dim cmd As SqlCommamd = nothing cmd.Connection=con cmd.CommandType = CommandType.Text cmd.CommandText = strSQL 'Open connection con.Open() 'Read data Dim myReader As SqlDataReader = com.ExecuteReader() 'Define dataset Dim myDS As DataSet = New DataSet() 'Load data to dataset myDS.Load(myReader , LoadOption.OverwriteChanges, "") myReader .Close() 'Close connection con.Close()
沒有留言:
張貼留言