定置管理图:asp.net编程中遇到sql语又有问题了!!!!!!
来源:百度文库 编辑:杭州交通信息网 时间:2024/05/25 20:32:47
Dim str As String
str = "workstation id=PRINTSERVER;packet size=4096;integrated security=SSPI;data source=PRINTSERVER;persist security info=False;initial catalog=mydata"
Dim cn As SqlClient.SqlConnection
cn = New SqlClient.SqlConnection(str)
cn.Open()
Dim strsql As String
strsql = "select password from people where username='worker1'"
Dim objcommand As SqlClient.SqlCommand
objcommand = New SqlClient.SqlCommand(strsql, cn)
objcommand.ExecuteNonQuery()
Response.Write(strsql)
cn.Close()
把select password from people where username='worker1'放到查询分析器里可以找到username=worker1的密码
可以运行之后结果为:
select password from people where username='worker1'
str = "workstation id=PRINTSERVER;packet size=4096;integrated security=SSPI;data source=PRINTSERVER;persist security info=False;initial catalog=mydata"
Dim cn As SqlClient.SqlConnection
cn = New SqlClient.SqlConnection(str)
cn.Open()
Dim strsql As String
strsql = "select password from people where username='worker1'"
Dim objcommand As SqlClient.SqlCommand
objcommand = New SqlClient.SqlCommand(strsql, cn)
objcommand.ExecuteNonQuery()
Response.Write(strsql)
cn.Close()
把select password from people where username='worker1'放到查询分析器里可以找到username=worker1的密码
可以运行之后结果为:
select password from people where username='worker1'
objcommand.ExecuteNonQuery()
执行SQL查询,会有返回值,而你根本不取他得返回值,怎么会有结果
Response.Write(strsql)
这句输出SQL语句,在执行查询得时候,sql语句是不会变得。
要想输出结果可以这样(c#语法,改成VB即可):
string rV=objcommand.ExecuteNonQuery(); //这里要根据返回值得类型来选择
Response.Write(rV);
没看懂什么意思
你把sql,conn fill 给DataSet读出结果再write出来
你用Response.Write(strsql) 当然输出sql语句了
来不得.