stored procedure

Y

Yoshitha

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
 
G

Guest

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:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top