EmersonH.Com

Transforming Knowledge into Power

  • Increase font size
  • Default font size
  • Decrease font size
Home VB.Net 2008 Data ADO.NET Dataset

ADO.NET Dataset

E-mail Print

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventA
Dim connetionString As String
Dim connection As SqlConnection
Dim command As SqlCommand
Dim adapter As New SqlDataAdapter
Dim ds As New DataSet
Dim i As Integer
Dim sql As String
connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User sql = "Your SQL Statement Here"
connection = New SqlConnection(connetionString)
Try
connection.Open()
command = New SqlCommand(sql, connection)
adapter.SelectCommand = command
adapter.Fill(ds)
adapter.Dispose()
command.Dispose()
connection.Close()
For i = 0 To ds.Tables(0).Rows.Count - 1
MsgBox(ds.Tables(0).Rows(i).Item(0) & " -- " & ds.Tables(0).Rows(i)
Next
Catch ex As Exception
MsgBox("Can not open connection ! ")
End Try
End Sub

Last Updated on Monday, 21 December 2009 17:39