问题描述
伙计们,
我已经尝试整天搜索谷歌,但它只给了我vb.net到mysql或ms访问的结果。我可以知道如何/在哪里可以找到关于连接vb.net windows应用程序和ms sql server 2008作为后端的教程?提前感谢。
Hi guys,
I already tried searching on google all day but it only gives me the result of vb.net to mysql or ms access. May i know how/where i can find tutorial about connecting vb.net windows application with ms sql server 2008 as backend? Thank in advance.
推荐答案
Imports System.Data
Imports System.Data.SqlClient
你需要一个连接对象,这来自上述标题:
You wil need a connection object, this comes from the aforementioned headers:
Dim conn As New SqlConnection("your connection string here")
当你想打开连接时,使用conn.Open()和conn.Close()相反。
当您向SQL Server发出命令时,应该打开连接。永远不要忘记关闭。
有关连接字符串应该是什么的更多信息,请转到 []
大多数情况下,连接字符串的模板将是:
Server = myServerAddress; Database = myDataBase; User Id = myUsername;
Password = myPassword;
有不同的命令可以执行不同的操作你想要的数据库任务;有时您想要执行INSERT,DELETE或UPDATE,您可能想要选择单个值,或检索表结果集。这些答案超出了这个问题的范围,所以我建议你再发一个问题。
When you want to open the connection use conn.Open() and conn.Close() for the opposite.
Connection should be open when you issue commands to SQL Server. Never forget to close.
For more information regarding what your connection string should be, go to http://www.connectionstrings.com/sql-server/[^]
Most of the time the template of the connection string will be:
"Server=myServerAddress;Database=myDataBase;User Id=myUsername;
Password=myPassword;"
There are different commands to perform the different tasks you want on a database; sometimes you want to do an INSERT, DELETE or UPDATE, you may want to select a single value, or retrieve a table result set. These answers are out of the scope of this question, so I suggest you issue yet another question.
这篇关于如何将ms sql server 2008与vb.net 2010连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!