Another newbie question ,
I'm modifying the IBuySpy Portal to include a company table to include in the registration process. My portal requires the user to register their company before moving on to register their user details. I wish to retrieve the CompanyID when the Register Company page (Register.aspx) uses the AddCompany Method from the CompanyDB Class (CompanyDB.vb), so that i can pass it to the subsequent page into a hidden field. This second page (register2.aspx) will then be able to submit the user details using the usual AddUser method in the UserDB class (security.vb) as per normal but will also add the CompanyID from the hidden field to a new column
in the Users Table.
Think i've got everthing right in the CompanyDB.vb using the Return command:
===========================================================
:
:
Dim parameterCompanyId As New SqlParameter("@CompanyID", SqlDbType.Int)
parameterCompanyId.Direction = ParameterDirection.Output
myCommand.Parameters.Add(parameterCompanyId)
' Execute the command in a try/catch to catch duplicate username errors
Try
' Open the connection and execute the Command
myConnection.Open()
myCommand.ExecuteNonQuery()
Return CInt(parameterCompanyId.Value) <----- NEW LINE
Catch
' failed to create a new company
Return -1
Finally
' Close the Connection
If myConnection.State = ConnectionState.Open Then
myConnection.Close()
End If
End Try
End Function
End Class
===========================================================
But what is the syntax to use in the Register.aspx file to get hold of the
returned value, put it in a variable, and pass it to Register2.aspx:
===========================================================
:
:
Sub RegisterBtn_Click(ByVal sender As Object, ByVal E As EventArgs)
' Only attempt a login if all form fields on the page are valid
If Page.IsValid = True Then
' Add New Company to Portal Company Database
Dim accountSystemCompany As New ASPNetPortal.CompanyDB()
If accountSystemCompany.AddCompany(CompanyName.Text, Address1.Text,
Address2.Text, Address3.Text, Town_City.Text, Postcode.Text,
Country.SelectedItem.Value, TelNum.Text, FaxNum.Text, CompanyEmail.Text,
Website.Text, Contact1.Text, Position1.Text, Contact2.Text, Position2.Text,
Contact3.Text, Position3.Text, MemberRates.SelectedItem.Value,
Payment.SelectedItem.Value) Then
??????What should go here to get the CompanyID, put it in a variable and pass it to the following page??????
Response.Redirect("Register2.aspx" & accountCompanyID)
Else
Message.Text = "Registration Failed! <" & "u" & ">" & CompanyName.Text & "<" & "/u" & "> is already registered." & "<" & "br" & ">" End If End If End Sub
:
:
===========================================================
Thanks for any help,
cheers
si
I'm modifying the IBuySpy Portal to include a company table to include in the registration process. My portal requires the user to register their company before moving on to register their user details. I wish to retrieve the CompanyID when the Register Company page (Register.aspx) uses the AddCompany Method from the CompanyDB Class (CompanyDB.vb), so that i can pass it to the subsequent page into a hidden field. This second page (register2.aspx) will then be able to submit the user details using the usual AddUser method in the UserDB class (security.vb) as per normal but will also add the CompanyID from the hidden field to a new column
in the Users Table.
Think i've got everthing right in the CompanyDB.vb using the Return command:
===========================================================
:
:
Dim parameterCompanyId As New SqlParameter("@CompanyID", SqlDbType.Int)
parameterCompanyId.Direction = ParameterDirection.Output
myCommand.Parameters.Add(parameterCompanyId)
' Execute the command in a try/catch to catch duplicate username errors
Try
' Open the connection and execute the Command
myConnection.Open()
myCommand.ExecuteNonQuery()
Return CInt(parameterCompanyId.Value) <----- NEW LINE
Catch
' failed to create a new company
Return -1
Finally
' Close the Connection
If myConnection.State = ConnectionState.Open Then
myConnection.Close()
End If
End Try
End Function
End Class
===========================================================
But what is the syntax to use in the Register.aspx file to get hold of the
returned value, put it in a variable, and pass it to Register2.aspx:
===========================================================
:
:
Sub RegisterBtn_Click(ByVal sender As Object, ByVal E As EventArgs)
' Only attempt a login if all form fields on the page are valid
If Page.IsValid = True Then
' Add New Company to Portal Company Database
Dim accountSystemCompany As New ASPNetPortal.CompanyDB()
If accountSystemCompany.AddCompany(CompanyName.Text, Address1.Text,
Address2.Text, Address3.Text, Town_City.Text, Postcode.Text,
Country.SelectedItem.Value, TelNum.Text, FaxNum.Text, CompanyEmail.Text,
Website.Text, Contact1.Text, Position1.Text, Contact2.Text, Position2.Text,
Contact3.Text, Position3.Text, MemberRates.SelectedItem.Value,
Payment.SelectedItem.Value) Then
??????What should go here to get the CompanyID, put it in a variable and pass it to the following page??????
Response.Redirect("Register2.aspx" & accountCompanyID)
Else
Message.Text = "Registration Failed! <" & "u" & ">" & CompanyName.Text & "<" & "/u" & "> is already registered." & "<" & "br" & ">" End If End If End Sub
:
:
===========================================================
Thanks for any help,
cheers
si