473,395 Members | 1,972 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,395 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 1469
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.