vb+http+xmlhttp返回无法读出问题
共分vb代码 和 putsingleinfo.asp代码记录能成功添加时数据库,就是无法获取到返回成功的提示retval变量
提示实时错误 ‘91’ 对象变量或with块变量未设置
请哪位大侠帮看看,谢谢喽!!!
知道vb在执行这句时程序报错了
strretval = ResponseXml.selectSingleNode("retval").Text
但是不知道原因,不会改呀,5555 ,谢谢,各位大侠帮改一改
下面这段是vb代码
Private Sub Command1_Click()
Dim httpRequest As MSXML2.XMLHTTP30
Set httpRequest = New MSXML2.XMLHTTP30
Dim strXML As String
'构造出要上传的XML串,这里节点使用中文
strXML = "<Request>" & _
"<youid>" & Text1.Text & "</youid>" & _
"<youname>" & Text2.Text & "</youname>" & _
"<youpwd>" & Text3.Text & "</youpwd>" & _
"</Request>"
Text4.Text = strXML
httpRequest.Open "POST", "http://localhost/putsingleinfo.asp", False
httpRequest.send strXML
'如果错误
If httpRequest.Status <> 200 Then
MsgBox httpRequest.statusText, , httpRequest.Status
Exit Sub
End If
'以下是判断数据是否正确提交
Dim strretval As String
Dim ResponseXml As DOMDocument
Set ResponseXml = New DOMDocument
Set ResponseXml = httpRequest.ResponseXml
' 执行到下面一句出错!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
strretval = ResponseXml.selectSingleNode("retval").Text
MsgBox strretval
End Sub
‘下面是putsingleinfo.asp代码
<%@ Language=VBScript %>
<%
Response.ContentType = "text/xml"
Set conn = Server.CreateObject("ADODB.connection")
conn.open "driver={Microsoft Access Driver (*.mdb)};dbq= " & Server.MapPath("lqdf.mdb")
Dim xmldom
Set xmldom = Server.CreateObject("MSXML.DOMDocument")
xmldom.Load Request
Dim youid, youname, youpwd
youid = xmldom.selectSingleNode("//youid").Text
youname = xmldom.selectSingleNode("//youname").Text
youpwd = xmldom.selectSingleNode("//youpwd").Text
Dim strsql, retval
On Error Resume Next
strsql = "insert into user(youid,youname,youpwd) values( '" & youid & " ','" & youname & "
','" & youpwd & " ')"
conn.Execute strsql
response.Write Err.Number
If Err.Number = 0 Then
retval = "数据成功提交 "
Else
retval = "数据提交失败,请检查你的数据 "
End If
Set xmldom = Nothing
Set conn = Nothing
%>
<?xml version="1.0" encoding="gb2312" ?>
<Response>
<retval><%=retval%></retval>
</Response>
源码上传了,请大侠帮改一改,谢谢!
http://pan.baidu.com/s/1mgt31zi