Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - how i can add new row in SQL db? plzz
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

how i can add new row in SQL db? plzz

 Post Reply Post Reply
Author
Cool_Man View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 23 March 2003
Location: Kuwait
Status: Offline
Points: 147
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cool_Man Quote  Post ReplyReply Direct Link To This Post Topic: how i can add new row in SQL db? plzz
    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
Back to Top
Cool_Man View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 23 March 2003
Location: Kuwait
Status: Offline
Points: 147
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cool_Man Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
Cool_Man View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 23 March 2003
Location: Kuwait
Status: Offline
Points: 147
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cool_Man Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.