We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Updating Database

Thread ID:

Created:

Updated:

Platform:

Replies:

362 Jun 11,2002 10:16 PM UTC Jun 14,2002 12:46 PM UTC Windows Forms 5
loading
Tags: FAQ
Administrator [Syncfusion]
Asked On June 11, 2002 10:16 PM UTC

Howcome I'm getting an error when I'm trying to save an empty string into the database? VB6 allows me to do that without any problems. I'm getting an error if the txtQty.text is empty. It won't let me save it coz it's empty. How do I get around it? .... row.item("Qty") = txtQty.text .... dataadapter.update(dsList, "List")

Clay Burch [Syncfusion]
Replied On June 12, 2002 04:27 AM UTC

A couple of things to check. Is Qty a numeric value in your database? Maybe that is why it would not accept an empty STRING. Try using a zero instead. Also, there are several properties floating around that are named AllowDBNull. For example, there is one in the datacolumn: MyTable.Columns("Qty").AllowDBNull = True Make sure all these are set properly. Another thing to try would be to conditionally set row("Qty") = DBNull.Value if the string is empty.

Administrator [Syncfusion]
Replied On June 12, 2002 08:38 AM UTC

I tried it but it only allows me to update one empty field.. both my field's datatypes are "text" 'this works.. if txtQty.text = "" then row.item("Qty") = DbNull.Value row.item("Price") = txtPrice.text row.item("Product") = txtProduct.text **** 'this doesn't work elseif txtQty.text = "" AND txtPrice.text = "" .. row.item("Qty") = DbNull.Value row.item("Price") = DbNull.Value row.item("Product") = txtProduct.text When two fields are empty then I'm getting an error in the dataadapter.update! I've also added the myTable.Columns("Qty").AllowDBNull = true inside my procedure but this is not doing anything.. i think.. pls. help! I've been stuck on this for almost a week already. :(

Clay Burch [Syncfusion]
Replied On June 13, 2002 05:32 AM UTC

You might try switching the order of your if clauses. Your elseif block will never be executed as the first alternative (your orignal if) will be true whenever your 2nd alternative is true. You also probably want to have an elseif for the price being "" too.

Administrator [Syncfusion]
Replied On June 13, 2002 09:09 PM UTC

I tried that but no luck! I don't think it's my if statements. b/c i checked it and it's going inside the elseif but it's just not executing it. it just won't allow me to insert two fields that are null. is there any other way of getting around it? coz i already checked the properties of the fields and the allowDbNull is set to true. so what wrong?? :( > You might try switching the order of your if clauses. Your elseif block will never be executed as the first alternative (your orignal if) will be true whenever your 2nd alternative is true. You also probably want to have an elseif for the price being "" too

Clay Burch [Syncfusion]
Replied On June 14, 2002 12:46 PM UTC

Try putting a Try-Catch around this problem code to see if any exceptions are being thrown in this code. That might help point to the problem.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;