Results 1 to 2 of 2

Thread: Open talbes and connections with code

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Open talbes and connections with code

    In VB6 I did this.

    Dim cn As New ADODB.Connection

    cn.ConnectionString = "provider=sqloledb.1;" _
    & "persist security info=false;" _
    & "user id=;password=;" _
    & "initial catalog=Temp;" _
    & "data source="
    cn.Open

    Dim rs As New ADODB.Recordset

    rs.CursorLocation = adUseClient
    rs.CursorType = adOpenDynamic
    rs.ActiveConnection = cn
    rs.LockType = adLockOptimistic

    rs.Open "Select * from EBY_PriceBk_Temp"

    How can do I do this in VB.net?

    Thanks
    David Wilhelm

  2. #2
    Thelonius
    Guest
    Imports System.Data
    Imports System.Data.SqlClient

    'Retrieve data subroutine


    ' Simple Binding and or data manipulation
    Dim ds As New DataSet()
    Dim sDA as New SqlDataAdapter("Select * from EBY_PriceBk_Temp", whatever_your_connection_string_is)

    ds.Tables.Add(New DataTable("Table1") )

    sDa.Fill(ds, "Table1")



    If you simply need to retrieve use the DataReader

    Dim sConn as New SqlConnection(whatever_your_connection_string_is)
    sConn.Open()

    Dim sCmd As New SqlCommand("Select * from EBY_PriceBK_Temp", sConn)

    Dim sDR as SqlDataReader = sCmd.ExecuteReader

    While sdr.Read
    ' some population code
    End While

    sConn.Dispose() ' if you are totally done with it
    sCmd.Dispose()

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