hi guys
I need assistance with SQL insert statement to
an access database. I want to insert values to a
particular table if the text box value is less than
0. below is the sample code.

dim value4 as integer
if integer.try parse(textbox4.text) then
    if value4 <=0 then
        dim cmd as new oledb.oledbcommand
        SQL="insert into accountsReceivable" & _
            "(receiptID,rdate,credit)"&_
            "values"&_
            "(:0,:1,:2)"
        cmd.connection = newconn
        cmd.transaction=mytransaction
        cmd.commandtext=SQL
        cmd.parameters.addwithvalue (":0",receiptID)
        cmd.parameters. addwithvalue(":1",now.date)
        cmd.parameters. addwithvalue(":2",credit)
        cmd.executenonquerry()
        cmd.dispose()
    end if
end if

I have a similar procedure which I want to
insert to the database if the text box value is
greater than 0.
thanks.

Is this not working, is there an error message?

Is cmd.parameters.addwithvalue (":0",receiptID) right - I may be wrong but I thought you used @ rather than : for parameters?

it is able to insert into the database but the problem is that the IF statement is not being followed.
thanks.

hi
its now fine. I had to alternate the statement such that the statement with the IF clause is first processed, then if the value of the text box is >=0 the program executes the Else part. my error was that the Else clause was misplaced.

thanks

Ok cool.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.