如何将ms sql server 2008与vb.net 2010连接? [英] how to connect ms sql server 2008 with vb.net 2010?

查看:83
本文介绍了如何将ms sql server 2008与vb.net 2010连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,



我已经尝试整天搜索谷歌,但它只给了我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.

推荐答案

我不知道有关教程,但可以按照以下说明进行连接:



您需要在每个类中使用下一个标题,以便使用连接或任何内容:

I don't know about a tutorial, but connection can be achieved following these instructions:

You need the next headers in every class you want to use connections or anything:
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发出命令时,应该打开连接。永远不要忘记关闭。



有关连接字符串应该是什么的更多信息,请转到 http://www.connectionstrings.com/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.


On MSDN [ ^ ] site;)
On MSDN[^] site ;)


试试LinqtoSql,非常简单!
Try LinqtoSql, it is very easy!


这篇关于如何将ms sql server 2008与vb.net 2010连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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