Connection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • trimp
    New Member
    • Feb 2008
    • 1

    Connection

    How To Connect The Vb.net With Sql
  • pkombli
    New Member
    • Feb 2008
    • 3

    #2
    Originally posted by trimp
    How To Connect The Vb.net With Sql
    declare the sqlclint

    connection
    command
    dataset


    later

    using connetion string u can

    ex:
    dim cn as new sqlconnetion
    cn.connetionstr ing="use provider"
    cn.open()

    Comment

    • kunal pawar
      Contributor
      • Oct 2007
      • 297

      #3
      this link may help you

      http://www.aspnettutor ials.com/tutorials/database/connect-sql-datasource-vb.aspx
      http://www.freevbcode. com/ShowCode.asp?ID =2226

      Comment

      • jamesd0142
        Contributor
        • Sep 2007
        • 471

        #4
        try using this

        [code=vb.net]
        Dim Cmd As OleDb.OleDbComm and
        Dim Con As OleDb.OleDbConn ection
        Dim Sql As String = Nothing
        Dim Reader As OleDb.OleDbData Reader
        Dim ComboRow As Integer = -1
        Dim Columns As Integer = 0
        Dim Category As String = Nothing
        Dim da As System.Data.Ole Db.OleDbDataAda pter
        Dim oDS As New System.Data.Dat aSet

        Con = New OleDb.OleDbConn ection("Provide r=sqloledb;Data Source=server;I nitial Catalog=databas e;User ID=sa;Password= " & txtserverpasswo rd.Text)

        sql = ""

        'Run Query
        oDS.Clear()
        Con.Close()
        Cmd = New OleDb.OleDbComm and(Sql, Con)

        Con.Open()
        da = New OleDbDataAdapte r(Sql, Con)
        da.Fill(oDS, "Table2")
        DGV.DataSource = oDS.Tables("Tab le2").DefaultVi ew
        DGV.Refresh()
        ToolStripStatus Label1.Text = "Query Run Successfully"
        Catch
        ToolStripStatus Label1.Text = "Query Did Not Run Successfully"
        End Try
        [/code]

        Comment

        Working...