Help please! Creating record in ASP for SQL Server!
Discussion
Right all i'm a bit stuck.
I've got a database table in SQL Server 2005 called "migrate" under the database name "NIC_TEST" and I need to create a simple web form with just name and email address to write to the database using the "Addnew" method in ASP (not .Net as i've not learnt that yet)
My problem is, I just cannot get it to work, and most websites I look at for help are writing to Access which is not much help!
Can anyone on here write me a basic script (I can understand it when I read it) that would make this work please as i've now spent the last 4 hours tearing my hair out doing battle with it!
Thanks!
I've got a database table in SQL Server 2005 called "migrate" under the database name "NIC_TEST" and I need to create a simple web form with just name and email address to write to the database using the "Addnew" method in ASP (not .Net as i've not learnt that yet)
My problem is, I just cannot get it to work, and most websites I look at for help are writing to Access which is not much help!
Can anyone on here write me a basic script (I can understand it when I read it) that would make this work please as i've now spent the last 4 hours tearing my hair out doing battle with it!
Thanks!
There are about a million examples of adding a record to a database using vbscript on google...
http://www.stardeveloper.com/articles/display.html...
What is your connection string btw? does your sql work ok in query analyser when connecting with the same credentials?
http://www.stardeveloper.com/articles/display.html...
What is your connection string btw? does your sql work ok in query analyser when connecting with the same credentials?
Nic Jones said:
I'm sure I tried that and it didn't work! 
It's so bloody annoying spending hours on end trying to hunt out a scripting problem!
It will work.
It's so bloody annoying spending hours on end trying to hunt out a scripting problem!
You need an Application variable with a DSN in it.
Application("DSN"
= "Driver=SQL Server;SERVER=SERVERNAME;DATABASE=DATABASENAME;UID=sa;PWD="Then you can simply open a recordset
Set rs = Server.CreateObject("ADODB.Recordset"

rs.Open sql,Application("DSN"
,adoOpenForwardOnly,adoLockReadOnly,adoCmdText or whatever.BTW. NEVER use AddNew or "clever" recordsets. All too often they fail to work or aren't portable across databases or whatever. Just use good old fashioned "SnapShot" type recordsets to read data. If you want to insert something build a SQL INSERT statement and execute it
sql = "INSERT INTO MYTABLE(MYFIELD) VALUES (" & strValue & "

Set conn = Server.CreateObject("ADODB.Connection"

conn.Open Application("DSN"

conn.Execute sql
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff


