如何从数据库中读取数据

时间:2015-01-16 14:42:43

标签: html sql asp-classic

我正在尝试从数据库中读取电子邮件地址,但它给我错误消息响应对象错误'ASP 0185:8002000e'缺少默认属性。是因为Response.Write不允许吗?有另一种方法,我可以从数据库中获取数据并存储到我的变量中吗?另外你如何在CDO.MESSAGE HTMLBODY上插入图像我使用标签,但不起作用。谢谢你的帮助。

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=MSDASQL.

 DIM objConn, bs, ossql
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open "Provider=MSDASQL.1;Password=**;Persist Security Info=True;User ID=**;Data Source=**"
    ossql = "SELECT email_addr FROM medacist_user WHERE username = '" & strUsername & "' AND health_system_code= '" & strHealth & "' AND facility_code = '"& strFacility & "'"
    Set bs = objConn.Execute(ossql)
   Dim storeEmail
 Response.Write bs("email_addr")
        

1 个答案:

答案 0 :(得分:-1)

bs被视为记录集。您可以构建HTML字符串或JSON字符串以传回浏览器。

Set bs = objConn.Execute(ossql)
Dim html = ""
Do While Not bs.EOF
   html = html & bs.Fields(0).Value
Loop
bs.Close

Response.write(html)