Query

boknat

Member
Joined
Oct 4, 2011
Messages
9
Programming Experience
Beginner
how to input data in mysql, different tables with one query?

is it possible to do in gridview in vb.net 2008?
 
First up, you have posted in the Windows Forms forum and there is no such thing as a GridView in Windows Forms, so that part of the question is irrelevant. Even if you mean a DataGridView it is still irrelevant, because that is a control for displaying data to the user and allowing them to edit it. It has nothing specific to do with databases.

To answer your question, it can't be done. If you want to insert or update data in two tables in a database then you need two INSERT or UPDATE statements. Depending on the database, you might be able to do that with a single command, e.g. SQL Server, or you may require two commands, e.g. Access. I would guess that MySQL would allow it to be done with one, i.e. include two SQL statements in the CommandText of one MySqlCommand, but you'd have to test that to make sure. In a SqlCommand for SQL Server you separate multiple SQL statements with semicolons. If you do need to use two commands then, if you're using MySqlDataAdapters to save the contents of a DataTable, make sure that you set AcceptChangesDuringUpdate to False for the first one and True for the second, otherwise the second one will have no effect.
 
you mean datagridview is just for viewing? but some says that it can update and insert data...

for my another question, i think there is a way to insert data with one query, but i still dont know how to do it, you think i can do it with a conjunction table?
 
Datagridview can be used to modify and add new rows to a datatable but this is nothing to do with any particular database. Google 'datatable' to understand why
 
Triggers would allow a single INSERT query to update two tables on MSSQL - no idea if mySQL allows the same.

At the end of the day, this is something you'd do at your database end, not within your code.
 
Back
Top