3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by kannadhasan
0

hello Awais
try this code

Dim cn As ADODB.Connection 'ADODB Connection Object
        Dim rs As New ADODB.Recordset 'Recordset Object
        Dim sqlStr As String ' String variable to store sql command
        
        Set cn = New ADODB.Connection
        
        cn.ConnectionString = "Provider = MSDASQL;" & _
            "Data Source=LocalServer;" & _
            "Initial Catalog=sample;" & _
            "Login ID=SERVANT;" & _
            "Driver=SQL Server;"

        cn.Open
 'your code        
        cn.Close
0

Note that is for connect ur frontend with sql database server

hi awaise ali,

to connect vb.net with data base first we need the sql connection.

so we write a connection string. to write a connection string first creat a connection variable like this

dim con as new sqlconnection

next we need the connection string that indicate the sql server

that is like
dim costring as string

constring="server=servername;userid=your suer id;password=your password;database="your database name"

after this you need to connect with the server

con=new sqlconnection(constring)

now u r connected with the data base server

after this
con.open() 'for open the connection

do your command here

con.close()

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.