J
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,StreetAddress2,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.ConnectionStrings("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.
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,StreetAddress2,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.ConnectionStrings("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.