Results 1 to 3 of 3

Thread: SQLConnection

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Enterprise
    Posts
    101

    SQLConnection

    how 2 do it in VB.NET?

    i want to connect to a sql db and fill a datagrid with the result of my query
    it's pretty different from vb6 :-/

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    I dont have my SQL example here..but you can find plenty of examples here

    http://www.gotdotnet.com
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    Dim oconn As SqlConnection = New SqlConnection()
    Dim ocmd As SqlCommand = New SqlCommand()
    Dim oDA As SqlDataAdapter = New SqlDataAdapter()
    Dim oDS As DataSet = New DataSet()

    oconn.ConnectionString = ".........."
    oconn.Open()

    ocmd.Connection = oconn
    ocmd.CommandText = "........."
    oDA.SelectCommand = ocmd
    oDA.Fill(oDS, "customers")

    DataGrid1.SetDataBinding(oDS, "Customers")
    Wind and waves resolves all problems.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width