Discussion Locked

Linking VB with SQL Server

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Im trying to link VB to an SQL database.Any code samples will be welcome

5 replies

by hemal

Hi,
To connect VB with SQL You just need few lines of codes..i'll give you hints,,

1)first define connection with passing necessary parameters
2)Then define a command or you can use an adodb connection.
3) If you use command, write following lines
with cmdXYZ
.active connection = 'your connection"
.command type = 'stored procedure' or 'string'
.command text = 'name of sp' or 'string query'
dim rs as new adodb.recordset
rs.recordset = .execute
END with

okay,,
all the best

by toanisht

1. Create a Data Source Name (DSN)
2. Select the database while you create the DSN.
3. Add reference to Microsoft ActiveX Data objects....
Open VB and the Project->References
4. Write the following code...
dim con as adodb.connection
dim rs as adodb.recordset

set con=new adodb.connection
set rs=new adodb.recordset

con.open "DSN=Name_Of_DSN"
rs. open "select * from table_name",con
...
...
rs.close
con.close

set rs=nothing
set con=nothing

by man_man

iam Mukund Garodhara From india
I wanto to Know about sql and vb linking
Please Guide me

This discussion is closed to new replies.