Forums

ASP

This topic is locked

Simple SQL insert code

Posted 10 Jan 2008 19:26:37
1
has voted
10 Jan 2008 19:26:37 paul wheatley posted:
Hello,

I am fairly new to SQL

I am looking for the correct code to update a Microsoft SQL database without using the dreamweaver INSERT function.

What i have so far is this.....

<%
dim db_driver,db_path
db_driver="Microsoft.Jet.OLEDB.4.0"
db_path="C:\mydatabase.mdb"

set conn=Server.CreateObject("ADODB.Connection"
conn.Provider=db_driver
conn.Open db_path
sql="INSERT INTO TBL_Main (animal, colour, food, home) VALUES ("monkey", "brown", "banana", "tree")&""
conn.Execute sql
conn.close
response.redirect("index.asp"
%>

This is what i used in Access but i am not sure what to change to get it to work in MS SQL.

Any help would be much appriciated.

Thanks

Replies

Replied 24 Jan 2008 13:53:46
24 Jan 2008 13:53:46 Vince Baker replied:
not sure if you have resolved this yet but basically you can set up an ODBC connection to the SSQL Server db and then use that connection.

There are syntax differences between access and MS SQL Server but for a simple input command like you have you will not have any issues.

Once you have created your odbc connection you can use dreamweaver to create a connection and then rip the code out if you do not want to use an include file.

Regards

Vince Baker
<strong>DMX Zone Manager</strong>

[VBScript | ASP | HTML | CSS | SQL | Oracle | AS400 | ERP Logic | Hosting]

Reply to this topic