| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

10-27-04, 20:50
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Australia
Posts: 183
|
|
Invalid use of null:Cstr
|
|
This is the error I receive when trying to submit a new record, and higlights this code
call rs.Open("SELECT @@IDENTITY As NewRecID", myCon)
nRecID = CStr(rs("NewRecID"))
call rs.Close
which is obviously the code creating new RecordID as new records are added.
I don't really have a control over creating this number it gets allocated,right?
Could somebody give me an advice as what should I be looking for,this has worked in the past and not sure when exactly it stopped working.
Thanks a lot everybody
|
|

10-28-04, 00:38
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
Code:
call rs.Open("SELECT @@IDENTITY As NewRecID", myCon)
nRecID = CStr(rs("NewRecID"))
call rs.Close
okie, that select statement if current returning null and you are trying to convert it to a string and thus your error.
@@IDENTITY returns the last-inserted identity value. Is the record that you are inserting using an identity column?? If not that would likely return a null.
I assume this follows straight after an insert statement yes?
edit: just checked, null is returned if no identity column was used in the last insert
|
Last edited by rokslide; 10-28-04 at 00:47.
|

10-28-04, 00:56
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Australia
Posts: 183
|
|
|
|
Yes you are correct,that is what i have realised it is null, because INSERT code before that is not executing but I can't see why, debugging the code shows, all the values as expected,have gone through all the field names, it updates correctly but not saving a newly submitted record.
pain in the a..
|
|

10-28-04, 01:00
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
have you tried executing to code directly against the database??
|
|

10-28-04, 01:00
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Australia
Posts: 183
|
|
can you explain a bit more,just like everything else my debuggin skills=VERY LIMITED
|
|

10-28-04, 01:04
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
grab the sql the you are sending to the database to insert the record by doing a response.write on the line before you execute it.
copy the sql and go to the database in the query analyzer and paste the sql in. then execute the statement in the analyzer.
that way you might see what is happening.
|
|

10-28-04, 01:07
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Australia
Posts: 183
|
|
Why didn't you say so, smart man, will do.
Ta
will let you know tomorrow how it went, have to nick out now
|
Last edited by zobernjik; 10-28-04 at 01:09.
|

10-28-04, 01:10
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
no worries, should at worse show the problem or rule out the sql as an issue
|
|

10-28-04, 21:54
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Australia
Posts: 183
|
|
Thanks for your idea, the problem was that INSERT statement didn't like the order of some fields because the varchar submitted was trying to save as a field int so once i got that sorted it is cool.
I am learning so much.
Ta
|
|

10-28-04, 21:56
|
|
Registered User
|
|
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
|
|
excellent, glad I could help.
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|