Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter problem

Status
Not open for further replies.

NotSoCunning

Technical User
May 3, 2005
64
GB
Hi guys,

I'm having a bit of a nightmare with using parameters for updating a record within my database. It keeps throwing the following error

"Parameter @desc has no default value"

The code that deals with the parameters is as follows:

Code:
sSQL = "UPDATE req SET strReqNo=@reqno, fkContractID=@contractid, strDescription=@desc, intValue=@value, intCostPlus=@costplus, strDesignBy=@desby, dteIssue=@isson, strIssueBy=@issby WHERE pkJobCardNo=@jcno"
        
cmd = New System.Data.OleDb.OleDbCommand(sSQL, dbcon)
dba.UpdateCommand = cmd

cmd.Parameters.Add("@jcno", OleDb.OleDbType.Integer).Value = jcno
cmd.Parameters.Add("@reqno", OleDb.OleDbType.Char).Value = reqno
cmd.Parameters.Add("@contractid", OleDb.OleDbType.Integer).Value = text
cmd.Parameters.Add("@desc", OleDb.OleDbType.Char).Value = desc
cmd.Parameters.Add("@value", OleDb.OleDbType.Currency).Value = value
cmd.Parameters.Add("@costplus", OleDb.OleDbType.Currency).Value = costplus
cmd.Parameters.Add("@desby", OleDb.OleDbType.Char).Value = desby
cmd.Parameters.Add("@isson", OleDb.OleDbType.Char).Value = isson
cmd.Parameters.Add("@issby", OleDb.OleDbType.Char).Value = issby

dbcon.Open()

cmd.ExecuteNonQuery()

dbcon.Close()

I've google'd and searched the forums but nothing seems to solve this problem. The variables assigned are set by textbox's and are all correct according to traces. I have an insert statement which runs off the same parameters which runs fine. I'm totally puzzled, any suggestions welcome.
 
Presuming the 'desc' var is = "" , then it might be that the field("@desc") is not allowed to have a null value and no default value has been set....

If var'desc' is not ="" - Then i dont know, sorry
 
desc = "some string" and is allowed to be empty by the db anyway. Desc gets set in the following code. The previous code is part of the updatedb method.

Code:
    Private Sub Submit_Command(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click


        jcno = tbCardNo.Text
        reqno = tbReqNo.Text
        value = tbValue.Text
        costplus = tbCost.Text
        desby = tbDesBy.Text
        issby = tbIssuedBy.Text
        isson = tbIssuedOn.Text
        desc = tbDesc.Text


        updatedb()

        Response.Redirect("main.aspx")

    End Sub
 
Have you tried debugging the app and executing the sProc in query analyser with the parameters being returned from your page to make sure the issues with the app not the sProc or table?

Rhys

"Vampireware /n/,a project, capable of sucking the lifeblood out of anyone unfortunate enough to be assigned to it, which never actually sees the light of day, but nonetheless refuses to die."

"I see dead pixels!
 
Eventually figured out what it was, it was posting back and reseting the variables. Nothing wrong with this section of code, which makes a nice change :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top