关于带有vb.net 2008的asp.net与sql server 2008之间的连接 [英] regarding to connection between asp.net with vb.net 2008 and sql server 2008

查看:63
本文介绍了关于带有vb.net 2008的asp.net与sql server 2008之间的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是.net的新手.我已经使用asp.net创建了一个表单,我想通过使用vb.net来将代码转换为该表单.我已经创建了一个主表..由于我是.net的新手,所以我不了解连接asp. net与vb.net和sql server..我需要逐步进行连接的方法..

I''m new to .net. Ive created a form using asp.net and i want code to that form by using vb.net.. I''ve created a master table.. since I''m new to .net, i do not know about connectivity asp.net with vb.net and sql server.. i need step by step method to connect..

推荐答案

从以下几个地方开始:
- http://msdn.microsoft.com/en-us/library/32c5dh3b.aspx [^ ]
- http://msdn.microsoft.com/en-us/library/kb9s9ks0.aspx [^ ]
- http://msdn.microsoft.com/en-us/library/system .data.sqlclient.sqlconnection.aspx [ ^ ]
Few places to start from:
- http://msdn.microsoft.com/en-us/library/32c5dh3b.aspx[^]
- http://msdn.microsoft.com/en-us/library/kb9s9ks0.aspx[^]
- http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx[^]


尝试一下:
Try this:
Using con As New SqlConnection(strConnect)
	con.Open()
	Using com As New SqlCommand("SELECT iD, description FROM myTable", con)
		Using reader As SqlDataReader = com.ExecuteReader()
			While reader.Read()
				Dim iD As Integer = CInt(reader("iD"))
				Dim desc As String = DirectCast(reader("description"), String)
				Console.WriteLine("ID: {0}:{1}", iD, desc)
			End While
		End Using
	End Using
End Using

您将需要在strConnect中设置连接字符串,但是如果您建立通过Server Explorer在VS中建立连接,属性"窗格将为您提供有效的字符串.

You will need to set up the connection string in strConnect, but if you establish a connection in VS via the Server Explorer, the Properties pane will give you the valid string.


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

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