vb.net的连接代码 [英] connectivity code for vb.net
本文介绍了vb.net的连接代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将vb.net与sql server连接.之后,我们如何检查信息是否正确存储.
解决方案
听起来像您是该领域的初学者吗?
在这里查看这些视频; http://msdn.microsoft.com/en-gb/vbasic/ff718212 [ ^ ]
//尝试为您的sqlconnection使用此代码
//首先以类class
声明所有Required对象 //例如.以下是声明
将objcon调暗为sqlclient.sqlconnection
//然后在formload事件中添加代码,如下所示
objcon =新的sqlclient.sqlconnection
objcon.connectionstring("datasource = sqlservername;初始目录=数据库名称; IntegratedSecurity = True")
//您的sqlconnection已在此处正确建立
//如果您想在表格中插入一些值,请看这里
//双击您的插入按钮并编写此代码
私有子btninsert(以Bayval发送者为对象,以byval e作为eventargs)处理btninsert.click
昏暗的objcom作为新的sqlclient.sqlcommand(插入表值(""+ textbox1.text +",""++ textbox2.text +"''),objcon)
objcon.open()
objcom.executenonquery()
objcon.close()
结束子
//然后将成功插入文本框值
how to connect vb.net with sql server. after that, how we can check whether information is properly storing. help me.
解决方案Sounds like you are a beginner to this area?
Check out these videos here; http://msdn.microsoft.com/en-gb/vbasic/ff718212[^]
//try this code for your sqlconnection
//first of all declare all Required object in form class
//eg. below is declarations
dim objcon as sqlclient.sqlconnection
//then on formload event add code whis is given below
objcon=new sqlclient.sqlconnection
objcon.connectionstring("datasource=sqlservername;initial catalog=databasename; integratedSecurity=True")
//your sqlconnection established here properly
// if you want to inser some values in table then look here
// double click on your insert button and write this code
private sub btninsert(bayval sender as object,byval e as eventargs) handles btninsert.click
dim objcom as new sqlclient.sqlcommand("insert into table values(''"+textbox1.text+"'',''"+textbox2.text+"'')",objcon)
objcon.open()
objcom.executenonquery()
objcon.close()
end sub
// then textbox values will be inserted successfully
这篇关于vb.net的连接代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文