Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AddNew isn't really adding

Status
Not open for further replies.

Christiana

Technical User
Apr 24, 2001
21
0
0
CY
I have the following code. Each time it returns the next number expected but it doesn't really add. Does anyone what the problem could be? I'm using MS Access.

dim conntemp
set conntemp=server.CreateObject("adodb.connection")
conntemp.Open myDSN
Dim rs
set rs=Server.CreateObject("ADODB.RecordSet")
strSQL="SELECT * FROM WATERMILL"

rs.Open strSQL, conntemp,adOpenDynamic, adLockPessimistic

'Make sure that there aren't any previous errors affecting
conntemp.Errors.Clear
On Error Resume Next
rs.AddNew
rs.Fields("Name")="'"&Request("Name")&"'"
..........
rs.Fields("Details")=Request("Details")

'Get the primary key of the record added
WatermillID=rs.Fields("WatermillID").Value
rs.Update
rs.close

Thank you in advance
Christiana
 
rs.Fields("Name")="'"&Request("Name")&"
WatermillID=rs.Fields("WatermillID").Value

these two doesn't look right?

rs.Fields("Name")= Request.Form("Name")
rs.Fields("Details")=Request.Form("Details")


Where are you getting the stuff to update the fields? is it from form or query string?

double check...when u add new you gotta supply the information into the database.

Hui Emagine Solutions, Inc.
 
also for the db connection,
you didn't specifiy how u were connecting? which database? which driver?

set cnn = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.RecordSet")
cnn.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=d:/Projects/billing/billing.mdb;"

addemployee_sql = "SELECT * FROM Clients"
rst.Open addemployee_sql,cnn,3,3

like that.

thanks,
hui Emagine Solutions, Inc.
 
This is the DSN I'm using:
myDSN="Provider=Microsoft.Jet.OLEDB.4.0;"
myDSN= myDSN & "Data Source="&server.mappath("Copy of watermill.mdb")&";"

I tried using
rs.AddNew
rs.Fields("Onomasia")="'"&Request.Form("Onomasia")&"'"
........
rs.Update
rs.close

'Get the primary key of the record added
WatermillID=rs.Fields("WatermillID").Value

instead but it still doesn't work
X-)
 
Just wanted to add that the autonumber of WatermillID is increased as it is supposed to on the Webpage and in the Database too!!
What's going on? PLS HELP
 
u do not need to increase the autonumber, when you insert a record without the autonumber which is the primary key, it should automatically increase it, even if you don't add it into the add.new Emagine Solutions, Inc.
 
rs.Fields("Onomasia")="'"&Request.Form("Onomasia")&"'"


don't do that do it this way

rs.Fields("Onomasia")=Request.Form("Onomasia")
Emagine Solutions, Inc.
 
I'm not increasing the autonumber. I just mentioned that the number I get returned is the one that it should be. If I have 200 records in my table then it returns 201. Then if I try to manually add to the DB the autonumber is 202.
I tried using
rs.Fields("Onomasia")=Request.Form("Onomasia")
but still it doesn't work.
Thanks
Christiana
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top