By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,119 Members | 2,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,119 IT Pros & Developers. It's quick & easy.

stored procedure

P: n/a
Hi
i've created one table and one stroed procedure to insert data into that
table.
i've created table like this

table Name=QA_QAuthor

EmailId Varchar primarykey.
Pwd varchar
Comments varchar allows null values
paypalacc varchar allows null values
rateperqueston numeric allows null values
Skills varchar
Stroed Procedure
CREATE PROCEDURE QA_Insert_QA
@email varchar(50),
@pwd varchar(50),
@comments varchar(50),
@paypal varchar(50),
@RPQ numeric,
@skills varchar(50)
AS
insert into QA_QuestionAuthors

values(@email,@pwd,@comments,@paypal,

@RPQ,@skills)
GO

am calling this stroed procedure in

asp.net like this


Dim cmdQAinsert As New OleDbCommand
cmdQAinsert.Connection = MyConn
cmdQAinsert.Transaction = t
cmdQAinsert.CommandType = commandType.StoredProcedure
cmdQAinsert.CommandText = "QA_Insert_QA"

Dim comments As New OleDb.OleDbParameter
comments.OleDbType = OleDbType.VarChar
comments.Direction = ParameterDirection.Input
comments.Value = Trim(txtComments.Text)

Dim email1 As New OleDb.OleDbParameter
email1.OleDbType = OleDbType.VarChar
email1.Direction = ParameterDirection.Input
email1.Value = Trim(txtEmail.Text)

Dim pwd As New OleDb.OleDbParameter
pwd.OleDbType = OleDbType.VarChar
pwd.Direction = ParameterDirection.Input
pwd.Value = pwdgen.pwdgen.RandomString()

Dim PayPalAcc As New OleDb.OleDbParameter
PayPalAcc.OleDbType = OleDbType.VarChar
PayPalAcc.Direction = ParameterDirection.Input
PayPalAcc.Value = Trim(txtPayPalAcc.Text)

Dim RatePerQues As New
OleDb.OleDbParameter
RatePerQues.OleDbType = OleDbType.VarChar
RatePerQues.Direction = ParameterDirection.Input
RatePerQues.Value =
Trim(txtRatePerQuestion.Text)

Dim skills As New OleDb.OleDbParameter
skills.OleDbType = OleDbType.Variant
skills.Direction = ParameterDirection.Input
skills.Value = Trim(ddlSkills.SelectedValue)

cmdQAinsert.Parameters.Add(email1)
cmdQAinsert.Parameters.Add(pwd)
cmdQAinsert.Parameters.Add(comments)
cmdQAinsert.Parameters.Add(PayPalAcc)
cmdQAinsert.Parameters.Add(RatePerQues
)
cmdQAinsert.Parameters.Add(skills)
res = cmdQAinsert.ExecuteNonQuery()
-----
----

if i entering data for all fields

then it is not giving any exception ,

the data is storing in backend table.
but when i enter data for few fields

and when am trying to run the

application then it is rising the following exception

"Input String is not in a correct format"

why am getting this error.
in the table i set allow null for 3

fields and for these 3 fields if i wont specify any data then it is giving
that exception if i specify data for these fields then am not getting any
errors.

can u tell how to solve this problem?

Thanx in advance
Yoshitha
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Yoshitha
if u let say a textbox empty and in ur procedure u parse it to integer or
float or any thing other than string this execption apper
to do that make a condation that when there is null entry u pass to ur
procedure 0 for int not null
Hope this help:)

"Yoshitha" wrote:
Hi
i've created one table and one stroed procedure to insert data into that
table.
i've created table like this

table Name=QA_QAuthor

EmailId Varchar primarykey.
Pwd varchar
Comments varchar allows null values
paypalacc varchar allows null values
rateperqueston numeric allows null values
Skills varchar
Stroed Procedure
CREATE PROCEDURE QA_Insert_QA
@email varchar(50),
@pwd varchar(50),
@comments varchar(50),
@paypal varchar(50),
@RPQ numeric,
@skills varchar(50)
AS
insert into QA_QuestionAuthors

values(@email,@pwd,@comments,@paypal,

@RPQ,@skills)
GO

am calling this stroed procedure in

asp.net like this


Dim cmdQAinsert As New OleDbCommand
cmdQAinsert.Connection = MyConn
cmdQAinsert.Transaction = t
cmdQAinsert.CommandType = commandType.StoredProcedure
cmdQAinsert.CommandText = "QA_Insert_QA"

Dim comments As New OleDb.OleDbParameter
comments.OleDbType = OleDbType.VarChar
comments.Direction = ParameterDirection.Input
comments.Value = Trim(txtComments.Text)

Dim email1 As New OleDb.OleDbParameter
email1.OleDbType = OleDbType.VarChar
email1.Direction = ParameterDirection.Input
email1.Value = Trim(txtEmail.Text)

Dim pwd As New OleDb.OleDbParameter
pwd.OleDbType = OleDbType.VarChar
pwd.Direction = ParameterDirection.Input
pwd.Value = pwdgen.pwdgen.RandomString()

Dim PayPalAcc As New OleDb.OleDbParameter
PayPalAcc.OleDbType = OleDbType.VarChar
PayPalAcc.Direction = ParameterDirection.Input
PayPalAcc.Value = Trim(txtPayPalAcc.Text)

Dim RatePerQues As New
OleDb.OleDbParameter
RatePerQues.OleDbType = OleDbType.VarChar
RatePerQues.Direction = ParameterDirection.Input
RatePerQues.Value =
Trim(txtRatePerQuestion.Text)

Dim skills As New OleDb.OleDbParameter
skills.OleDbType = OleDbType.Variant
skills.Direction = ParameterDirection.Input
skills.Value = Trim(ddlSkills.SelectedValue)

cmdQAinsert.Parameters.Add(email1)
cmdQAinsert.Parameters.Add(pwd)
cmdQAinsert.Parameters.Add(comments)
cmdQAinsert.Parameters.Add(PayPalAcc)
cmdQAinsert.Parameters.Add(RatePerQues
)
cmdQAinsert.Parameters.Add(skills)
res = cmdQAinsert.ExecuteNonQuery()
-----
----

if i entering data for all fields

then it is not giving any exception ,

the data is storing in backend table.
but when i enter data for few fields

and when am trying to run the

application then it is rising the following exception

"Input String is not in a correct format"

why am getting this error.
in the table i set allow null for 3

fields and for these 3 fields if i wont specify any data then it is giving
that exception if i specify data for these fields then am not getting any
errors.

can u tell how to solve this problem?

Thanx in advance
Yoshitha

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.