4399神将三国武将大全:asp.net编程中遇到sql语又有问题了!!!!!!

来源:百度文库 编辑:神马品牌网 时间:2024/04/26 07:18:00
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'

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语句了

来不得.