Jump to content

Using ADO to update/insert to SQL


Lukifer122
 Share

Recommended Posts

WARNING... NEWBIE ALERT!!Ok, I've been teaching myself ASP, SQL and ADO, and I seem to have hit a dead end. I'm not able to get an answer anywhere for this, so hopefully I can get an answer here. I using an MSDE database with ONE table, and trying to insert/update records through an ASP page. The idea is that internet users can submit information for addition to the db. Well, while following along with the ADO section on W3Schools, I got the to ADO Add section, and customized the pages to suit my needs. I changed the code on the demo_add.asp page to display the error code, and it shows up as error: -2147217865. After searching around on google and newsgroups, this error matches tons of things, but not my scenario. Any suggestions anyone? I can post more info if needed! PLEASE HELP!

Link to comment
Share on other sites

My expertise is strictly with php and mysql, as is a huge number of the web developers out there. I guarantee you'll never find a queston in php that you can't google and find and answer pretty easily, and if you're teaching your self... you might consider switching over :)sorry I can't help you with your question... I've just seen this thread kinda laying there for a while and figured I might as well reply with something, eh?

Link to comment
Share on other sites

Please paste the complete error code and your asp code/sql query...

Error number: -2147217900INSERT INTO [maintenance] (datereceived,requesttakenby,priorityofissue,requestreceivedfrom) VALUES ('040404','four','mediumrare','4321') I have it display the submitted query after the error message, and that's what it spits out after I try to add a new record. As a side note, I can update records, just not add them. The ADO insert section on this site says this:"If the table contains a primary key, make sure to append a unique, non-Null value to the primary key field (if not, the provider may not append the record, or an error occurs) "I have a primary key field which is set to unique identifier. It should generate that on it's own should it not?
Link to comment
Share on other sites

I removed my primary key (which was set as a uniqueidentifier) and the insert works just fine. So I guess my question now is "how can I append a unique ID to each record during the insert process?"-Luke

Why dont you use the ADO Record set to add new records.set conn = Server.CreateObject("ADODB.Connection")set rs = Server.CreateObject("ADODB.Recordset")rs.open "table",conn ' not sure something like this... rs.addnewif you have a primary key and its an unique key with autonumber,you dont have to specify here.. recordset takes care of it. (Do you have primarykey as a autonumber in your database)rs.fields("yourfieldname")rs.fields("yourfieldname1")rs.fields("yourfieldname2")and so on.... 'remember to update it.. rs.Updaters.close set rs = nothing and now close your connection... it should work
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...