If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > asp.net connecting to access database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-20-08, 11:58
aa_86 aa_86 is offline
Registered User
 
Join Date: Feb 2008
Posts: 49
asp.net connecting to access database

hi, i have created a database on microsoft access 2003.
I have created a website in asp.net( visual basic). I have a page on the website where customers can make an order.

there is a customer table and a order table in my database. The way i have done is is i have created a text box for each attribute and a button. once the fields are filled out and the butoon clicked the records are updated in the database.

however the problem is i can only enter data into one table. e.g the customer name, address, tel no etc is entered and when buton clicked data is updated in the database. but how can i enter data into 2 diffrent tables at once with the click of one button.

This is the code that i use to enter data to one table, what i want to do is add data to two tables that are in a relationship:


imports.......etc

Public strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("Customer.mdb")

Protected Sub submit1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit1.Click

Dim cmd As New OleDbCommand("INSERT INTO Customer(Name,EMailAddress)VALUES('" & name.Text & "','" & email.Text"')", New OleDbConnection(strConn))

cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
End Sub



I would be very greatful for your help and would like to thank you a million in advance.
Reply With Quote
  #2 (permalink)  
Old 03-20-08, 14:37
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Keep the connection open, execute 3 differet queries?
Code:
Open connection
    execute 1st query
    execute 2nd query
    execute 3rd query
close connection
I don't have an internet connection on my development PC at the moment so I can't be much more help than pseudo code at the moment!

Let us know how you get on
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 03-20-08, 14:51
aa_86 aa_86 is offline
Registered User
 
Join Date: Feb 2008
Posts: 49
database connection

hi, ok i have found out how to insert into different tables,

you have to execute three commands,

add data into customer table,

get the customer id created,

and then add data into the order table with the retrieved customer id.

But i do not know how to code this

i have looked around, and everyone talks about entering data into one table,

or just retrieving the created id, i really need to know how to code this.

Your help will be really valued.

Thank You

AA
Reply With Quote
  #4 (permalink)  
Old 04-09-08, 14:05
aa_86 aa_86 is offline
Registered User
 
Join Date: Feb 2008
Posts: 49
anyone know how to do this please, ive searched everywhere but cant find it.

thankls
Reply With Quote
  #5 (permalink)  
Old 04-09-08, 18:13
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Apologies, I could have sworn I had already responded to this post!


...Aparently not, but I have found the reply I meant to have at least linked to

Retrieve NewID after Insert (Using MS ACCESS)
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On