Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IBuySpy Syntax Question

Status
Not open for further replies.

oddball

Technical User
Mar 17, 2000
64
GB
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(&quot;Register2.aspx&quot; & accountCompanyID)

Else

Message.Text = &quot;Registration Failed! <&quot; & &quot;u&quot; & &quot;>&quot; & CompanyName.Text & &quot;<&quot; & &quot;/u&quot; & &quot;> is already registered.&quot; & &quot;<&quot; & &quot;br&quot; & &quot;>&quot; End If End If End Sub
:
:

===========================================================

Thanks for any help,

cheers

si



 
Your if statement on the addCompany may work but isn't quite correct. The AddCompany function returns the companyId correct? Do this instead

dim CompanyID as integer

CompanyID = 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)

if CompanyID <> -1 then
AddUser(parameters, CompanyID)
end if


That should do it I think
[peace]
 
Cheers Zarcom,

got it working a treat :) :)

many thanks
 
must be I have never heard of it before.
Means ..easily
..right away
..without problem
..a different way

I have no clue can u explain [peace]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top