473,287 Members | 2,682 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Inserting new records in MSSQL db problem

Hi all. Created a simple table in my db. 3 colums one is a Int set for
autoincrement. Itentity True, seed 1, Incremement 1, null False.
The other colums are simple VarChar(50) null false on the first and true on
the last. Nothihng complicated here.

create a simple test app in VS2005 and connect to MSSQL2005 server, no
problem there. I can see it in Designer and preview the 3 rows of test data
I added.

Now, I create a form1 and DRAG from Datasources using Grid or Detail (it
makes no difference as the results are the same) on to my form and allow VS
to create a NavBar and either a grid or lables and text box's depending on
my selection (see above).

Build and run the app.

I can see the 3 test data rows previously entered fine.

Now, press the + key on NavBar to enter new record, start entering data,
Identity adds the next number in sequence as it should in the ID column, I
enter data in the two columns and press Save key on the NavBar and BOOM.

The following line of code generates the error: "IDENTITY_INSERT is set to
off"
Me.TblBarrelLgthTableAdapter.Update(Me.Gibbons_SQL DataSet.tblBarrelLgth)

What is wrong here? I have looked at the table settings and they look OK.
The rest is VS generated code. I just don't understand what is going on here
with the error. If Identity is generating the autoincrement number as it
should why should save (the above code) be upset? I didn't change the value.
This just to simple to go wrong. Appreciate any suggestions or help here. I
am just to close to the problem at this point I guess. BTW, I am a .NET
newbie. I come from other languages so please keep that in mind when
discussing this with me. ( In other words keep in simple for me.. lol.)

Robert


Jun 12 '07 #1
3 1465
Robert,

And it is nothing more than this after you made your table.
http://www.vb-tips.com/dbpages.aspx?...2-b1ed16424252

Cor
"Robert Johnson" <jo*******@sbcglobal.netschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hi all. Created a simple table in my db. 3 colums one is a Int set for
autoincrement. Itentity True, seed 1, Incremement 1, null False.
The other colums are simple VarChar(50) null false on the first and true
on the last. Nothihng complicated here.

create a simple test app in VS2005 and connect to MSSQL2005 server, no
problem there. I can see it in Designer and preview the 3 rows of test
data I added.

Now, I create a form1 and DRAG from Datasources using Grid or Detail (it
makes no difference as the results are the same) on to my form and allow
VS to create a NavBar and either a grid or lables and text box's depending
on my selection (see above).

Build and run the app.

I can see the 3 test data rows previously entered fine.

Now, press the + key on NavBar to enter new record, start entering data,
Identity adds the next number in sequence as it should in the ID column, I
enter data in the two columns and press Save key on the NavBar and BOOM.

The following line of code generates the error: "IDENTITY_INSERT is set to
off"
Me.TblBarrelLgthTableAdapter.Update(Me.Gibbons_SQL DataSet.tblBarrelLgth)

What is wrong here? I have looked at the table settings and they look OK.
The rest is VS generated code. I just don't understand what is going on
here with the error. If Identity is generating the autoincrement number as
it should why should save (the above code) be upset? I didn't change the
value. This just to simple to go wrong. Appreciate any suggestions or help
here. I am just to close to the problem at this point I guess. BTW, I am a
.NET newbie. I come from other languages so please keep that in mind when
discussing this with me. ( In other words keep in simple for me.. lol.)

Robert


Jun 12 '07 #2
And that's exactly what I did Cor. No joy.

Your Tip ----
Open a new project.

Click on Data -Add New DataSource and follow the wizard
Click on Data -Show Datasources
Drag from the at the left opened window your table to the form <---?? Drag
from the ?? at the left... ( I presume you mean icon)
Solution Explorer the Show All files Icon to show all files

You have now a lot of samples with a strongly typed dataset
End Your Tip---

Why do I have a problem with the Identity column? VS generated code should
know about it and account for it.
Robert

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:ev**************@TK2MSFTNGP06.phx.gbl...
Robert,

And it is nothing more than this after you made your table.
http://www.vb-tips.com/dbpages.aspx?...2-b1ed16424252

Cor
"Robert Johnson" <jo*******@sbcglobal.netschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
>Hi all. Created a simple table in my db. 3 colums one is a Int set for
autoincrement. Itentity True, seed 1, Incremement 1, null False.
The other colums are simple VarChar(50) null false on the first and true
on the last. Nothihng complicated here.

create a simple test app in VS2005 and connect to MSSQL2005 server, no
problem there. I can see it in Designer and preview the 3 rows of test
data I added.

Now, I create a form1 and DRAG from Datasources using Grid or Detail (it
makes no difference as the results are the same) on to my form and allow
VS to create a NavBar and either a grid or lables and text box's
depending on my selection (see above).

Build and run the app.

I can see the 3 test data rows previously entered fine.

Now, press the + key on NavBar to enter new record, start entering data,
Identity adds the next number in sequence as it should in the ID column,
I enter data in the two columns and press Save key on the NavBar and
BOOM.

The following line of code generates the error: "IDENTITY_INSERT is set
to off"
Me.TblBarrelLgthTableAdapter.Update(Me.Gibbons_SQ LDataSet.tblBarrelLgth)

What is wrong here? I have looked at the table settings and they look OK.
The rest is VS generated code. I just don't understand what is going on
here with the error. If Identity is generating the autoincrement number
as it should why should save (the above code) be upset? I didn't change
the value. This just to simple to go wrong. Appreciate any suggestions or
help here. I am just to close to the problem at this point I guess. BTW,
I am a .NET newbie. I come from other languages so please keep that in
mind when discussing this with me. ( In other words keep in simple for
me.. lol.)

Robert



Jun 12 '07 #3
Created new database and tables and that fixed it for some reason.. previous
database was created using SQL scripts generated by a import utility. Must
have had some problems that got by all the checks in MSSQL and Case. Go
figure...

Thanks for looking for me...

Robert

"Robert Johnson" <jo*******@sbcglobal.netwrote in message
news:e0**************@TK2MSFTNGP04.phx.gbl...
And that's exactly what I did Cor. No joy.

Your Tip ----
Open a new project.

Click on Data -Add New DataSource and follow the wizard
Click on Data -Show Datasources
Drag from the at the left opened window your table to the form <---??
Drag from the ?? at the left... ( I presume you mean icon)
Solution Explorer the Show All files Icon to show all files

You have now a lot of samples with a strongly typed dataset
End Your Tip---

Why do I have a problem with the Identity column? VS generated code
should know about it and account for it.
Robert

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:ev**************@TK2MSFTNGP06.phx.gbl...
>Robert,

And it is nothing more than this after you made your table.
http://www.vb-tips.com/dbpages.aspx?...2-b1ed16424252

Cor
"Robert Johnson" <jo*******@sbcglobal.netschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
>>Hi all. Created a simple table in my db. 3 colums one is a Int set for
autoincrement. Itentity True, seed 1, Incremement 1, null False.
The other colums are simple VarChar(50) null false on the first and true
on the last. Nothihng complicated here.

create a simple test app in VS2005 and connect to MSSQL2005 server, no
problem there. I can see it in Designer and preview the 3 rows of test
data I added.

Now, I create a form1 and DRAG from Datasources using Grid or Detail (it
makes no difference as the results are the same) on to my form and allow
VS to create a NavBar and either a grid or lables and text box's
depending on my selection (see above).

Build and run the app.

I can see the 3 test data rows previously entered fine.

Now, press the + key on NavBar to enter new record, start entering data,
Identity adds the next number in sequence as it should in the ID column,
I enter data in the two columns and press Save key on the NavBar and
BOOM.

The following line of code generates the error: "IDENTITY_INSERT is set
to off"
Me.TblBarrelLgthTableAdapter.Update(Me.Gibbons_S QLDataSet.tblBarrelLgth)

What is wrong here? I have looked at the table settings and they look
OK. The rest is VS generated code. I just don't understand what is going
on here with the error. If Identity is generating the autoincrement
number as it should why should save (the above code) be upset? I didn't
change the value. This just to simple to go wrong. Appreciate any
suggestions or help here. I am just to close to the problem at this
point I guess. BTW, I am a .NET newbie. I come from other languages so
please keep that in mind when discussing this with me. ( In other words
keep in simple for me.. lol.)

Robert




Jun 12 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Oren | last post by:
Hi, I have an Access application with linked tables via ODBC to MSSQL server 2000. Having a weird problem, probably something i've done while not being aware of (kinda newbie). the last 20...
3
by: Oren | last post by:
Hi, I've posted this message over at the ms-sql newsgroup – no luck. Maybe some one here could help. I have an Access application with linked tables via ODBC to MSSQL Server 2000. Having a...
0
by: sherif | last post by:
Hi, I'm making an application using C# and i connect through it to a database made by MSSQL server but i have a problem when inserting or updating in the database in arabic that each arabic...
1
by: gouse | last post by:
Hello Friends, In a Table I am inserting more than 50,000 Records one by one. It was taking a lot of time . Is it There any good approach/solution for inserting records more than 50,000 one by one...
4
by: LetMeDoIt | last post by:
Greetings, I'm using ASP to retrieve from MSSQL and I then populate a table. After several months of successfull retrieves, this same code now bombs out. It turns out that if I clear out from...
3
by: veerapureddy | last post by:
Hai everybody, i like to insert some records into database from html form by entering data.my problem is how can i check , whether a record is available in database about a particular...
7
by: omeek | last post by:
I'm new to MSSQL (Have used MySQL for a little while) and am completely stuck. I have searched the net for days now and am amazed at how little info is out there for MSSQL. I am selecting multiple...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
5
by: rando1000 | last post by:
Okay, here's my situation. I need to loop through a file, inserting records based on a number field (in order) and if the character in a certain field = "##", I need to insert a blank record. ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.