我如何将VB.net2008与SQL Server2008连接 [英] how i connect VB.net2008 with SQL Server2008

查看:334
本文介绍了我如何将VB.net2008与SQL Server2008连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法创建VB.net 2008与SQL Server 2008的连接,
请向我发送相同的代码.

I can''t create a connection of VB.net 2008 with SQL Server 2008,
Please send me the code of the same

推荐答案

Google确实是您应该优先考虑的地方.我用谷歌搜索了与VB.Net的数据库连接",这是超过180万个结果中的第一个:

http://www.homeandlearn.co.uk/net/nets12p4.html [ ^ ]
Google really is the first place you should look. I googled "database connection with VB.Net", and this was the first of over 1.8 MILLION results:

http://www.homeandlearn.co.uk/net/nets12p4.html[^]


www.connectionstrings.com [ ^ ]非常适合将连接字符串获取到任何数据库.
www.connectionstrings.com[^] is good for getting connection strings to any database.


Dim sConnect as string
sConnect &= "Data Source=" & ServerName & ";"
               sConnect &= "Initial Catalog=" & Database & ";"
               sConnect &= "User Id=" & UserName & ";"
               sConnect &= "Password=" & Password & ";"
             
addConnection = New SqlConnection

           If addConnection.State = ConnectionState.Open Then addConnection.Close()
           addConnection.ConnectionString = sConnect
           addConnection.Open()
           addCommand = New SqlCommand


使用此SqlCommand


Do what you want with this SqlCommand


这篇关于我如何将VB.net2008与SQL Server2008连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆