tags:

views:

34

answers:

2

I know connection of MS Access and VB. I don't know connection of SQL with VB. Please provide some code examples.

+2  A: 

Assuming MS SQL and VB6, try this article:

Connecting to a SQL Server database using ADODB

Edit: Whoops, assumed wrong.

You can also visit ConnectionStrings.com for other connection strings, such as SQL 2005 and SQL 2008.

LittleBobbyTables
+2  A: 

Here's some basic code using VB.NET that will open and close a connection to MSSQL:

Imports System.Data.SqlClient
Dim SqlConn As New SqlConnection
SqlConn.ConnectionString = "Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;"
SqlConn.Open()
SqlConn.Close()
SqlConn.Dispose()

That should meet your request i believe. If it is indeed VB6, then it will be a completely different syntax.

fortheworld