|
|||
|
help in connecting to database
hi
I am trying to add records through asp to sql database. But I couldnt somehow. I am pasting the code which I tried to write. Can anybody tell the reason why its not reaching to database. Appreciate your help. <% FUNCTION fixQuotes(theString) fixQuotes = Replace (theString, \"\'\",\"\'\'\" ![]() END FUNCTION username = TRIM( Request( \"username\" )) password = TRIM( Request( \"password\" )) IF username <> \"\" AND password <> \"\" THEN mySQL = \"INSERT Webusers (username,password ) VALUES \" mySQL = MySQL & \"(\'\"&fixQuotes(username) & \"\',\'\"& fixQuotes(password) & \"\')\" Set Con=Server.CrateObject( \"ADODB.Connection\" ) Con.Open \"DSN=test;DATA SOURCE=sqlsrvrname;UID=sa;PWD=sa;DATABASE=name\" END IF %> <html> <head><title>Insert Data</title> <body> <form mehtod=\"post\" action=\"insertData.asp\"> <p>Username: <input name=\"username\" size=20> <p>Password: <input name=\"password\" type=\"password\" size=20> <p><input type=\"submit\" value=\"add Data\"> </form> </body> </html> |
| Sponsored Links |
|
|||
|
Re:help in connecting to database
seems to be there are few errors in the code,
here is the basic shell it should be create test datasource name from ODBC administrator first. Here is the ASP code to connect to SQl Server using ADODB. You can include your cleanup code anywhere. <% yourname = request.form(\"yourname\" yourpass = request.form(\"yourpass\" Set cn = Server.CreateObject(\"ADODB.Connection\" ![]() Set rs = Server.CreateObject(\"ADODB.Recordset\" ![]() sql = \"insert into Webusers (username,password)\" sql = sql & \" values( \'\" & yourname & \"\' , \'\" & yourpass & \"\' )\" cn.Open \"test\" rs.Open sql, cn %> Hope this helps. if not let me know ,I will provide working full ASp scripts for you to be able to run any DML statements. Thanks, sanereddy |
|
|||
|
Use this code for creating a DSN less connection to ur database
<% dim con dim adocon Set adoCon = Server.CreateObject("ADODB.Connection") Con = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Enter your Database name here") %> |
| Sponsored Links |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [FAQ] FileMaker Pro - database for Macintosh and Windows | Martin Trautmann | Tech FAQ | 0 | 10-19-2005 12:37 AM |
| Comp.software-eng FAQ (Part 0): periodic postings and archives | David Alex Lamb | Tech FAQ | 2 | 06-27-2004 05:15 AM |
| Comp.software-eng FAQ (Part 0): periodic postings and archives | David Alex Lamb | Tech FAQ | 2 | 05-23-2004 05:15 AM |
| Comp.software-eng FAQ (Part 0): periodic postings and archives | David Alex Lamb | Tech FAQ | 3 | 04-18-2004 05:15 AM |
| [FAQ] FileMaker Pro - database for Macintosh and Windows | Martin Trautmann | Tech FAQ | 0 | 04-17-2004 07:26 AM |