|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Does anybody know how to add data to multiple access tables through a vb form. I need to pass the UniqueID from my identification table to all my other related tables in the database, so when my users enter the data into the master table they are also entering the uniqueID into the other tables.
Thanks.. Help...................... |
|
#2
|
||||
|
||||
|
you would have to run multiple insert statements to insert the data in the tables.
|
|
#3
|
|||
|
|||
|
Thanks for that will try it out on Monday..
|
|
#4
|
||||
|
||||
|
Hi there! Would you care to elaberate and give an exaple?
I seem to have A VBScript error: Error Type: Microsoft VBScript compilation (0x800A0401) Expected end of statement /add_backup.asp, line 30, column 24 rsAddMovie.Open strSQL1 strSQL2, adoCon Column 24 is immediately after the 1 in: strSQL1. Here's the code. I'll bold what ever I feel is important to see. It works great with adding info to a database with one table in a database, but I need to add info to two tables. /////////////////////////////ASP Code///////////////////////////////// <%@ LANGUAGE="VBScript" %> <% 'Dimension variables Dim adoCon Dim rsAddMovie Dim strSQL1 Dim strSQL2 'Create an ADO connection object Set adoCon = Server.CreateObject("ADODB.Connection") 'Set an active connection to the Connection object using DSN connection adoCon.Open "DSN=movie" 'Create an ADO recordset object Set rsAddMovie = Server.CreateObject("ADODB.Recordset") 'Initialise the strSQL variables with the SQL statements to query the database strSQL1 = "SELECT tblMovies.Name, tblMovies.GenreID, tblMovies.Director, tblMovies.YearReleased, tblMovies.Length, tblMovies.RatingID, tblMovies.Review, tblMovies.CodecID, tblMovies.CDs, tblMovies.Notes FROM tblMovies;" strSQL2 = "SELECT tblActors.Fname, tblActors.Lname;" 'Set the cursor type we are using so we can navigate through the recordset rsAddMovie.CursorType = 2 'Set the lock type so that the record is locked by ADO when it is updated rsAddMovie.LockType = 3 'Open the recordset with the SQL query rsAddMovie.Open strSQL1 strSQL2, adoCon 'Tell the recordset we are adding a new record to it rsAddMovie.AddNew 'Add a new record to the recordset rsAddMovie.Fields("MovieName") = Request.Form("txtMovieName") rsAddMovie.Fields("GenreID") = Request.Form("optGenre") rsAddMovie.Fields("Director") = Request.Form("txtDirector") rsAddMovie.Fields("YearReleased") = Request.Form("txtYearReleased") rsAddMovie.Fields("Length") = Request.Form("Length") rsAddMovie.Fields("RatingID") = Request.Form("optRating") rsAddMovie.Fields("Review") = Request.Form("txtReview") rsAddMovie.Fields("CodecID") = Request.Form("txtCodec") rsAddMovie.Fields("CDs") = Request.Form("txtCds") rsAddMovie.Fields("Notes") = Request.Form("txtNotes") rsAddMovie.Fields("Fname") = Request.Form("txtFname") rsAddMovie.Fields("Lname") = Request.Form("txtLname") 'Write the updated recordset to the database rsAddMovie.Update 'Reset server objects rsAddMovie.Close Set rsAddMovie = Nothing Set adoCon = Nothing 'Redirect to the guestbook.asp page Response.Redirect "http://localhost/movie.asp" %> |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Adding data to multiple tables (VB) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|