开发者

How to connect SQL with VB?

开发者 https://www.devze.com 2023-01-10 11:25 出处:网络
I know connection of MS Access and VB. I don\'t know connection of SQL with VB. Pleas开发者_JAVA技巧e provide some code examples.Here\'s some basic code using VB.NET that will open and close a connect

I know connection of MS Access and VB. I don't know connection of SQL with VB. Pleas开发者_JAVA技巧e provide some code examples.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消