Question about...

Question about...

am 16.01.2008 17:40:14 von JJ297

Can someone take a look at my stored proc and code behind page to let
me know why isn't Titleid going into the database? I can't figure it
out!

I have a gridview on the other page and carrying the TitleID over to
the next page which works well.

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
Response.Redirect("checkoutItem.aspx?TitleID=" &
GridView1.SelectedValue)
End Sub

Here's the stored procedure:

CREATE procedure AddLoanRequest

@RequestorEmail varchar (75),
@RequestDate datetime,
@Fname varchar (50),
@Lname varchar (50),
@PhoneNum char (10),
@JobTitleID int,
@StreetAddress1 varchar (50),
@StreetAddress2 varchar (50),
@City varchar (50),
@State char (2),
@Zip char (5),
@ZipPlus4 char (4)

AS
set NOCOUNT on
declare @TitleID int

insert into Requestors
(RequestorEmail, RequestDate,
Fname,Lname,PhoneNum,JobTitleId,StreetAddress1,StreetAddress 2,City,State,Zip,ZipPlus4)

values(@RequestorEmail,
@RequestDate,
@Fname,
@Lname,
@PhoneNum,
@JobTitleID,
@StreetAddress1,
@StreetAddress2,
@City,
@State,
@Zip,
@ZipPlus4)

set @titleid = SCOPE_IDENTITY() --grabbing the id

select @titleid as titleid --return to caller for email

GO

All fields are going into the database besides Titleid

Here's the code behind to submit into the db after the form is filled
out:

Protected Sub Submit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Submit.Click

Dim conn As New
Data.SqlClient.SqlConnection(ConfigurationManager.Connection Strings("TrainUserConnectionString").ConnectionString)


Dim cmd As New Data.SqlClient.SqlCommand
With cmd
.Connection = conn
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "AddLoanRequest"
.Parameters.AddWithValue("@RequestorEmail", EmailAdd.Text)
.Parameters.AddWithValue("@RequestDate", LoanDate.Text)
.Parameters.AddWithValue("@FName", FName.Text)
.Parameters.AddWithValue("@LName", LName.Text)
.Parameters.AddWithValue("@PhoneNum", PhNoTxt.Text)
.Parameters.AddWithValue("@JobTitleID", JobTxt.Text)
.Parameters.AddWithValue("@StreetAddress1",
Street1Txt.Text)
.Parameters.AddWithValue("@StreetAddress2",
Street2Txt.Text)
.Parameters.AddWithValue("@City", CityTxt.Text)
.Parameters.AddWithValue("@State", StateTxt.Text)
.Parameters.AddWithValue("@Zip", ZipcodeTxt.Text)
.Parameters.AddWithValue("@ZipPlus4", ZipPlusTxt.Text)


End With
conn.Open()
Dim x As Integer

x = cmd.ExecuteScalar 'will bring back my quesID for the email


lbloutcome.Text = "Your entry was submitted into the
database."


conn.Close()

All fields go into the database besides the titleid. Can someone tell
me what I'm missing?

Thanks.

Re: Question about...

am 16.01.2008 17:52:03 von Leon Mayne

"JJ297" wrote in message
news:1a437420-3923-41d0-bd2e-93e3cb101ee2@21g2000hsj.googleg roups.com...
> set @titleid = SCOPE_IDENTITY() --grabbing the id

Obvious question, but have you made sure you have an identity column on
Requestors? Presumably a column called TitleId?

Re: Question about...

am 16.01.2008 18:57:30 von JJ297

On Jan 16, 11:52=A0am, "Leon Mayne" wrote:
> "JJ297" wrote in message
>
> news:1a437420-3923-41d0-bd2e-93e3cb101ee2@21g2000hsj.googleg roups.com...
>
> > set @titleid =3D SCOPE_IDENTITY() --grabbing the id
>
> Obvious question, but have you made sure you have an identity column on
> Requestors? Presumably a column called TitleId?

That's it the identity column is not TitleID but RequestorID. Okay
will try that now. Thanks!