Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to update tables in vb.net simultaneously.

that is i have 2 tables name data and sort.
if i make any changes/updation in data table that change will also be reflected in sort table also.

i had initially done insertion to multiple tables simultaneously by creating
2 insert query separated by semi colon.

like supose i enter enter values in data table, so my same values were getting inserted in sort table also.

but same way how to do the updation and delete query.

can anyone help me please.
Posted
Comments
Nirav Prabtani 5-Aug-13 6:24am    
can you describe fields of both tables???
[no name] 5-Aug-13 6:28am    
try to use INNER JOIN..
sudeshna from bangkok 5-Aug-13 6:41am    
data table fields-
lot_no,type,shape,size,place,dt(date)
sort table fields
lot_no,name,type,shape,size,place,issue_dt
sudeshna from bangkok 5-Aug-13 6:45am    
can you give me the query for inner join, i dont know.

If I am not wrong, you want to do Insert/Update/Delete operations on multiple tables.

So, in that case, why are you going for queries?
Just call a Stored Procedure and pass all the parameters.

Inside that procedure, just Insert/Update/Delete to the tables with respective data.
 
Share this answer
 
Comments
sudeshna from bangkok 5-Aug-13 6:42am    
but i am inserting my data from user end(front end) from vb.net
sudeshna from bangkok 5-Aug-13 6:43am    
yes i have done multiple insertion in multiple table simultaneously by wriring multiple insert statement separated by semi colon
sudeshna from bangkok 5-Aug-13 6:43am    
Dim cn As New SqlConnection("Data Source=.\INSTANCE;initial catalog=record;user=sa;password=gariahat")
Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
Dim ds As New DataSet
'Dim dr As SqlDataReader
cmd.Connection = cn
cn.Open()
cmd.CommandText = "insert into data(lot_no,type,shape,size,place,weight,dt) values (' " & TextBox1.Text & " ',' " & ComboBox1.Text & " ',' " & TextBox3.Text & " ',' " & TextBox4.Text & " ',' " & TextBox5.Text & " ',' " & TextBox6.Text & " ','" & Format(CDate(DateTimePicker1.Value), "MM/dd/yyyy") & " ');insert into sort(lot_no,type,shape,size,place,weight) values (' " & TextBox1.Text & " ',' " & ComboBox1.Text & " ',' " & TextBox3.Text & " ',' " & TextBox4.Text & " ',' " & TextBox5.Text & " ',' " & TextBox6.Text & " ');insert into fullsort(lot_no,type,shape,size,place,weight) values (' " & TextBox1.Text & " ',' " & ComboBox1.Text & " ',' " & TextBox3.Text & " ',' " & TextBox4.Text & " ',' " & TextBox5.Text & " ',' " & TextBox6.Text & " ')"
cmd.ExecuteNonQuery()
MsgBox("Data successfully added", MsgBoxStyle.Information)
gencatid()
Me.DataTableAdapter.Insert(TextBox1.Text, ComboBox1.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text, DateTimePicker1.Value)
Me.DataTableAdapter.Fill(Me.RecordDataSet.data)
Me.TextBox1.Text = ""
Me.ComboBox1.Text = ""
Me.TextBox3.Text = ""
Me.TextBox4.Text = ""
Me.TextBox5.Text = ""
Me.TextBox6.Text = ""
Me.DateTimePicker1.Text = ""
sudeshna from bangkok 5-Aug-13 6:44am    
see this is the code i have written separated by semi colon- data and sort table
sudeshna from bangkok 5-Aug-13 6:45am    
i dont know how to write a stored procedure. but how can i call it from the front end.
If you are using SQL Server 2005 or higher try making making use of the OUTPUT clause.
 
Share this answer
 
Comments
sudeshna from bangkok 5-Aug-13 9:20am    
how to do that? yes i am using sql server management studio 2008
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900