Richiet23
01-29-2007, 12:37 PM
I am using ASP.NET in visual studio 2005 and am connected to a database. the database has two tables, users and items. The item table has a composite key, made up from username (the prmary key from username table) and item name (Item table primary key).
i can add a users details to the database, via the code:
Function InsertUser(ByVal NewUsername As String, ByVal NewTitle As String, ByVal NewSurname As String, ByVal NewForename As String, ByVal NewAddressLine1 As String, ByVal NewAddressLine2 As String, ByVal NewCounty As String, ByVal NewCountry As String, ByVal NewPostcode As String, ByVal NewEmail As String) As Integer
Dim connectionString As String = _
"Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; " & _
" Data Source=C:\Documents and Settings\Compaq_Owner\Desktop\WebSite2\App_Data\proto.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
Dim querystring As String = "INSERT INTO [tblUser] (Username, Title, Surname, Forename, AddressLine1, AddressLine2, County, Country, Postcode, Email) " & _
"values (@Username, @Title, @Surname, @Forename, @AddressLine1, @AddressLine2, @County, @Country, @Postcode, @Email)"
Dim cmd As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
cmd.CommandText = querystring
cmd.Connection = dbConnection
What i need help with is adding an item to the database for a specific user. say the user id was USER1, I need to add a an item to USER1s account, how do i go about directing the item to add to this username?
i can add a users details to the database, via the code:
Function InsertUser(ByVal NewUsername As String, ByVal NewTitle As String, ByVal NewSurname As String, ByVal NewForename As String, ByVal NewAddressLine1 As String, ByVal NewAddressLine2 As String, ByVal NewCounty As String, ByVal NewCountry As String, ByVal NewPostcode As String, ByVal NewEmail As String) As Integer
Dim connectionString As String = _
"Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; " & _
" Data Source=C:\Documents and Settings\Compaq_Owner\Desktop\WebSite2\App_Data\proto.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
Dim querystring As String = "INSERT INTO [tblUser] (Username, Title, Surname, Forename, AddressLine1, AddressLine2, County, Country, Postcode, Email) " & _
"values (@Username, @Title, @Surname, @Forename, @AddressLine1, @AddressLine2, @County, @Country, @Postcode, @Email)"
Dim cmd As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
cmd.CommandText = querystring
cmd.Connection = dbConnection
What i need help with is adding an item to the database for a specific user. say the user id was USER1, I need to add a an item to USER1s account, how do i go about directing the item to add to this username?