vb数据库连接帮助. [英] vb database connection help.

查看:81
本文介绍了vb数据库连接帮助.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是具有Visual Basic的初学者,我需要帮助,因为我有一个大学项目的星期一截止日期.

我正在制作一个工具,用户可以在文本框中输入名称,然后软件会自动从名为database1的数据库中调出该名称的相关信息.
如果数据库看起来像下面的例子:

姓名d.o.b地址
user1 01/01/1987 10 1st street
user2 02/02/1988 11 2nd street

我有两种形式,form1和form2.

如何告诉vb从数据库中获取在form1的文本框txtname.text中输入的名称的d.o.b到在form2的名为txtdob.text的文本框中?

以及最初如何将数据库连接到vb Windows窗体?

p.s.我正在使用Visual Basic 2008 Express Edition



i am a beginner with visual basic and i need help as i have a deadline for monday for a university project.

i am making a tool where the user enters a name in a text box and the software automatically brings up the related information for that name from a database called database1.

if the database looks like the one below as an example:

name d.o.b address
user1 01/01/1987 10 1st street
user2 02/02/1988 11 2nd street

and i have 2 forms, form1 and form2.

how do i tell vb to get the d.o.b of the name entered in the text box txtname.text on form1 to a text box called txtdob.text on form2 from the database?

and how do i initially connect the database to my vb windows form?

p.s. i am using visual basic 2008 express edition

thank you in advance for any help much appreciated.

推荐答案

您将需要使用System.Data.SqlClient命名空间.您需要安装SQL Server 2008(有一个免费版本).您将需要知道如何使用SQL SELECT语句.您将使用SqlCommand和SqlConnection类.您将需要知道如何建立连接字符串.您需要具有有效的数据库用户名/密码.您可能想要使用构造函数或属性在表单之间传递数据. Google其中的一些术语,您提出解决方案应该没有问题.
You''ll need to make use of the System.Data.SqlClient namespace. You''ll need to have SQL Server 2008 installed (there is a free version). You''ll need to know how to use a SQL SELECT statement. You''ll make use of the SqlCommand and SqlConnection classes. You''ll need to know how to build a connection string. You''ll need to have a valid database user/password. You''ll probably want to pass data between forms using either constructors or properties. Google some of those terms and you should have no problem coming up with a solution.


好吧,如果您愿意学习的话,请遍历这些
Well, if you willing to learn, go through these tutorials


这篇关于vb数据库连接帮助.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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