Print Page | Close Window

how i can add new row in SQL db? plzz

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=7048
Printed Date: 31 March 2026 at 4:31pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: how i can add new row in SQL db? plzz
Posted By: Cool_Man
Subject: how i can add new row in SQL db? plzz
Date Posted: 06 November 2003 at 11:03am

Hi,

i had just now convert my access database to SQL database,

My question:

in my database there is table cold: (tblnames), and it's include two columns (id_name) and (name), and the DATA TYPE of the column (id_name) is (AutoNumber

with access database when i want to add new row in it, i have to write the following code:

Set rsCategory = Server.CreateObject("ADODB.Recordset")
rsCategory.LockType = 3
strSQL = "select * from tblnames;"

if not rsCategory.EOF then

rsCategory.addnew

rsCategory("name") = STRING

rsCategory.update

the access database will add STRING in the column: (name), and  automatically will insert new number in column(id_name)

but when i have now to add new row in SQL database with same code, it give me this error:

Microsoft OLE DB Provider for SQL Server error '80040e2f'

Cannot insert the value NULL into column 'Thread_ID', table 'noor.noorsa.tblThread'; column does not allow nulls. INSERT fails

it's mean that you must insert new number in cloumn (id_name) !!

and you know that the DATA TYPE of (id_name) column is: AutoNumber.

so, what is the problem and what i must do plzz ??!! 



-------------


Thanks for all



Replies:
Posted By: Cool_Man
Date Posted: 06 November 2003 at 11:34am

Sorry,

there is caution:

in SQL database there is NO DATA TYPE: (AutoNumber)

and when i convert Access DataBase to SQL DataBase, the column(id_name) which the DATA TYPE for it is: (AutoNumber),

converted to DATA TYPE (int) in SQL DataBase,

So, it will not automatically add new number in column (int) when i add new row.

Can anybody help me plzz ??



-------------


Thanks for all


Posted By: michael
Date Posted: 06 November 2003 at 12:13pm
You're on the right track, set it to int and the enable identity on that column (Design Table, bottom part)

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: Cool_Man
Date Posted: 06 November 2003 at 12:21pm

thanks michael for your help

and now there is another question plzz,

how i can change the (identity) column to true if the SQL DataBase in the HOST ?

if it's in my computer i must make it with SQQL Server Enterprise Manager,

but if it in the host, how i can do it ?

it's will be defecult if i must update all my table to the SQL server in the host !



-------------


Thanks for all


Posted By: fernan82
Date Posted: 07 November 2003 at 3:51pm
You doit exactly the same way as you doit localy with Enterprise Manager, only instead of connecting to 127.0.0.1 or using Windows auth you would have to connect to your host's server.

On your control panel you should be able to find the address to the sql, then on enterprise manager right-click the server group, then choose new sql server registration and complete the wizard.

-------------
FeRnAN
http://www.danasoft.com/">



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net