Hello, everybody.
I have typed DataSet ( dsMain ), that contains table ( ReferenceCycle ). In the program I make changes in that table, using generated by VS typed table adapter ( taReferenceCycle ) and values seems to gets inserted. And when I'm trying to update database with this - nothing happens. Here's part of my code:

taReferenceCycle.InsertQuerry(newCycle);
taReferenceCycle.Update(dsMain.ReferenceCycle);
dsMain.ReferenceCycle.AcceptChanges();

What am I doing wrong?
Any help would be greatly appreciated :)

Recommended Answers

All 11 Replies

What's newCycle datatype?
Look I tried that

BlogEngineDataSetTableAdapters.StudentTableAdapter s =
new rying.BlogEngineDataSetTableAdapters.StudentTableAdapter();
BlogEngineDataSet dsMain = new BlogEngineDataSet();
s.Insert(1000, "d", "a", "a", DateTime.Now);
//s.Update(dsMain.Student);
//dsMain.AcceptChanges();

Hello, Ramy.
Thanks for helping me :) newCycle has string type. The InsertQuerry I've created by adding queries in Wizard. My table ReferenceCycle consists from 2 fields (cycleId - It counts automatically; name - string, that I pass as argument into InsertQuerry method).

Also, my DataSet is changing perfectly. The only thing - is that I can't pass changes, that I've made, to database :(

It's also works with my defined insert query

BlogEngineDataSetTableAdapters.StudentTableAdapter tblStudent =
new trying.BlogEngineDataSetTableAdapters.StudentTableAdapter();
//BlogEngineDataSet dsMain = new BlogEngineDataSet();
tblStudent.InsertQuery(11, "d", "a", "a", DateTime.Now);

Try to take a variable from your table adapter then use its InsertQuery.
-Check TableAdapter properties that InsertCommand is not none.

Didn't you "Add new data source" then lmlmlaa... and VS generates for you DataSet?? very strange really!!

InsertCommand value is "INSERT INTO [ReferenceCycle] ([name]) VALUES (@p1)". DataSet is also generated by VS (if you're talking about that).

The last question, do you use VS 2008?

yes

Don't know really!!! I don't do any custom code, it generates, I'm calling, everything is OK! if you don't have SQL SP2, and don't use Express edition of SQL Server, try to run your application as administrator...

I use Express edition.

I solved this. I moved my database (with dataset, adapters) into new (non-startup) project in the same solution and it's working now :) Unfortunately I have no explanation of that O.o

As I said it's from strange problems you can meet!
I'm happy because you solved it :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.