Inserting new records in MSSQL db problem

  • Thread starter Thread starter Robert Johnson
  • Start date Start date
R

Robert Johnson

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_SQLDataSet.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
 
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
 
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
 
Back
Top