stored procedure

Discussion in 'ASP .Net' started by Yoshitha, Feb 22, 2005.

  1. Yoshitha

    Yoshitha Guest

    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
     
    Yoshitha, Feb 22, 2005
    #1
    1. Advertising

  2. 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
    >
    >
    >
     
    =?Utf-8?B?c2FyYQ==?=, Feb 22, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sarmad Aljazrawi

    New Stored Procedure Template in .Net

    Sarmad Aljazrawi, Dec 16, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    540
    Sarmad Aljazrawi
    Dec 16, 2003
  2. ES
    Replies:
    2
    Views:
    1,535
    jgy3183
    Aug 20, 2004
  3. Patrick
    Replies:
    2
    Views:
    5,956
    Gopinath S
    Feb 15, 2005
  4. Mike P
    Replies:
    0
    Views:
    3,313
    Mike P
    Jun 19, 2006
  5. AlexWare
    Replies:
    2
    Views:
    764
    Paul Uiterlinden
    Oct 23, 2009
Loading...

Share This Page