Monday, March 12, 2012

How to add record into SQL Server 2000?

How can I add the record into my company SQL Server 2000 database from the website register page?

This is my codes:
<%
Dim sql,rs

Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\InetPub\wwwroot\daly\fpdb\market.mdb"

sql="INSERT INTO testing (fname,lname)"
sql=sql & " VALUES "
sql=sql & "('Shawn', 'mike')"

objConn.Execute sql
objConn.close
%>

This is my error:
Microsoft JET Database Engine error '80004005'

Operation must use an updateable query.

/VITA_SHOW/test_VITAFormhandler.asp, line 137

Thank you very much!!!

Shawn
scn@.daly.comNot sure why you are getting that error, but a much better design strategy is to create a stored procedure that inserts the record based upon supplied parameters. You should avoid giving applications direct access to data tables.|||your problem might have been either...

1. you dont have the NT permissions for a file-based database or for the folder that contains the file
2. the file might have been exclusive
3. theres another thats still connected that needs to be closed

for more info on issuing this problem, goto MS white papers

http://support.microsoft.com/default.aspx?scid=kb;EN-US;306269|||What type of object is "testing"? I suspect it's not a table, but rather a query.|||You say that you are updating SQL Server 2000, but your code seems to be looking at a Microsoft Access database - the Jet engine and the .mdb extension both refer to Access.

Andy|||objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\InetPub\wwwroot\daly\fpdb\market.mdb"

First off, the database is Access, not SQL, as can be seen from the connection string above.

If you are trying to use access, then the reason for the error is that the IUSR_SERVERNAME (or the authenticated web user, if applicable) does not have write access to the folder and file at c:\InetPub\wwwroot\daly\fpdb\market.mdb. Make sure you set read/write privileges for IUSR_SERVERNAME or Everyone for both the MDB file and the folder in which it resides.

If you are in fact trying to connect to an MSSQL server, you will need to do one of the following:

a) If you have access to the ODBC configuration, set up a DSN, and use the following syntax:

objConn.Open "DSNNAME","USERNAME","PASSWORD"

b) If you don't have access to create a DSN, use the following syntax:

objConn.Open "Driver={SQL Server};UID=USERNAME;password=PASSWORD;database=DA TABASE_NAME;server=SERVER_NAME_OR_IP"

No comments:

Post a Comment