asp.net如何从数据库读取一个字段的值然后赋值给一个参数
asp.net如何从数据库读取一个字段的值然后赋值给一个参数?就像asp中的username=rs("username")一样,请问怎么是实现呀?...
asp.net如何从数据库读取一个字段的值然后赋值给一个参数?
就像asp中的username=rs("username")一样,请问怎么是实现呀? 展开
就像asp中的username=rs("username")一样,请问怎么是实现呀? 展开
1个回答
展开全部
Dim conn As SqlConnection
Dim cs As SqlCommand
Dim rs As SqlDataReader
Dim sql As String
Dim UserName as string
sql = "select * from [User] where id=1"
conn = New SqlConnection(Application("conn"))
cs = New SqlCommand(sql, conn)
conn.Open()
rs = cs.ExecuteReader()
If rs.Read Then
UserName = Trim(rs("UserName"))
End if
rs.close()
conn.close()
Dim cs As SqlCommand
Dim rs As SqlDataReader
Dim sql As String
Dim UserName as string
sql = "select * from [User] where id=1"
conn = New SqlConnection(Application("conn"))
cs = New SqlCommand(sql, conn)
conn.Open()
rs = cs.ExecuteReader()
If rs.Read Then
UserName = Trim(rs("UserName"))
End if
rs.close()
conn.close()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |