locked
classic asp can't connect sql server RRS feed

  • Question

  • User1840611328 posted

    Hi,

    I'm testing this code to connect sql server, but the page didn't savethe data to sql server. Is there any configuration that I need to set to enable the connection?

    <body>
    <form name="Form" action="*.asp" method="post">
    <input name="Name" type="text"><br>
    <input name="Password" type="password"><br>
    <input  type="submit">
    </form>
    </body>
    </html>

    <%
     dim sql
     sql ="select * from table-name "
     set conn=server.createobject("adodb.connection")
     conn.open "provider=sqloledb;source=local;uid=sa;pwd=*******;database=db-name"
     set rs=server.createobject("adodb.recordset")
     rs.open sql,conn,3,2
     rs.addnew
     rs("name")=request.form("Name")
     rs("pwd")=request.form("Password")
     rs.update
    %>
    Sunday, October 22, 2017 2:06 PM

Answers

  • User-2064283741 posted

    <br>
    https://www.connectionstrings.com is a good site for showing different ways of connecting to a db.&lt;br&gt;<br>
    Also check for any errors. &lt;br&gt;<br>
    Not working isn't very useful there will be errors in the IIS logs, event log, SQL server logs, etc&lt;br&gt;<br>
    Make sure you see communication to the SQL server. Check firewalls, etc allow connections through to it.&lt;br&gt;<br>
    &lt;br&gt;<br>
    Oh do not use sa as your account to connect up your db setup a less privileged account.<br>
    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Sunday, October 22, 2017 11:06 PM

All replies

  • User-2064283741 posted

    <br>
    https://www.connectionstrings.com is a good site for showing different ways of connecting to a db.&lt;br&gt;<br>
    Also check for any errors. &lt;br&gt;<br>
    Not working isn't very useful there will be errors in the IIS logs, event log, SQL server logs, etc&lt;br&gt;<br>
    Make sure you see communication to the SQL server. Check firewalls, etc allow connections through to it.&lt;br&gt;<br>
    &lt;br&gt;<br>
    Oh do not use sa as your account to connect up your db setup a less privileged account.<br>
    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Sunday, October 22, 2017 11:06 PM
  • User-460007017 posted

    Hi jimschan,

    I didn't find any error which is related to the display of database data in form. So maybe you need to check the connections between IIS and sql server. Just ensure your connection string could be accessed. Please check sql server authentication log could help you fix this issue. In IIS, you should not require to configure anything unless you need to use IIS connection string.

    Bes Regards,

    Yuk Ding

    Monday, October 23, 2017 7:17 AM