Insert data in two tables using stored procedure
I have two input fields viz. name and street in the webpage. When the user input name and street, how can I insert that data in two tables Customer and Address using stored procedure with parameters? The table structure is like this
Address(address_id,street)
Customer(customer_id,address_id,name) // address_id is the foreign key.
When the user input street and name from webpage, Address table should be filled first and the address_id of Address table should be input to the Customer table along with name.
Could you please help me how to implement this using triggers and stored procedure?
Thanks!
Uttam
[B]Question asked by visitor Uttam[/b]
Re: Insert data in two tables using stored procedure
Dear Friends,
I face the same problem while i am doing project and i found solution that
[COLOR="Blue"] Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oracon As New Data.OleDb.OleDbConnection
oracon.ConnectionString = "Provider=MSDAORA.1;Password=patel;User ID=scott;data source=adarsh;Persist Security Info=True"
oracon.Open()
Dim cmd As New Data.OleDb.OleDbCommand
Dim param1 As New Data.OleDb.OleDbParameter
Dim param2 As New Data.OleDb.OleDbParameter
param1.ParameterName = "param1"
param1.OleDbType = Data.OleDb.OleDbType.VarChar
'param1.Size = 12
param1.Direction = Data.ParameterDirection.Input
param1.Value = "20-05-2007"
param2.ParameterName = "param2"
param2.OleDbType = Data.OleDb.OleDbType.VarChar
'param2.Size = 5
param2.Direction = Data.ParameterDirection.Input
param2.Value = "AHD"
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Connection = oracon
cmd.CommandText = "example1"
cmd.Parameters.Add(param2)
cmd.Parameters.Add(param1)
'cmd.CommandText = "{execute Example1(?,?)}"
'cmd.CommandText = "{execute Example2(param2)}"
cmd.ExecuteNonQuery()[/COLOR]
This solution is for my program, you can get hint
Thanks,
Adarsh Patel