.NET/Oracle8i - Inserting Null.

G

Guest

I have a numeric column in Oracle which is populated using a .NET Datagrid.
The problem is whenever i try to fill it with empty value when the user
clears the value that is filled already, I get an error. Iam pasting chunks
of code :

Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.UpdateCommand
Dim key As String = DataGrid1.DataKeys(e.Item.ItemIndex).ToString
Dim intStepID, strCheckList_Name, strSQL, strResource, strStatus,
strGraceDate, strMan, strAnswer, strOrder, strAuditRemarks, strURL
Dim strLBound, strHBound As Int32
Dim tBox As TextBox

Dim r As dsChkListModify.CHECKLIST_INSTRow
r = DsChkListModify1.CHECKLIST_INST.FindByCI_ID(key)

tBox = CType(e.Item.Cells(7).Controls(0), TextBox)
strHBound = tBox.Text
r.CI_LBOUND = strLBound

finally I do a TRY & CATCH to update the db:

Try
OleDbDataAdapter1.Update(DsChkListModify1)
DataGrid1.DataBind()
Label1.ForeColor = Color.Green
Label1.Text = "Update was successfull!"
Catch ex As Exception
If Len(ex.ToString()) > 0 Then
Label1.ForeColor = Color.Red
Label1.Text = ex.Message '"An Error occured. Please enter a
valid value!"
End If
Finally
End Try
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
End Sub

Thanks in adv.
RajSB
 
G

Guest

Rephrasing the question...

When the user empties the text box in EDIT mode in a .NET datagrid, and when
I try to put this empty value back to the column in Oracle, ("" or Null?) I
get an error saying :

"Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct
format."
......................................
......................................

[FormatException: Input string was not in a correct format.]
Microsoft.VisualBasic.CompilerServices.DoubleType.Parse(String Value,
NumberFormatInfo NumberFormat)
Microsoft.VisualBasic.CompilerServices.DoubleType.Parse(String Value)
Microsoft.VisualBasic.CompilerServices.IntegerType.FromString(String Value)

[InvalidCastException: Cast from string "" to type 'Integer' is not valid.]

Hope this is clear.

Thanks
Raj.SB
 
G

Guest

Capture the original value (DataSet in cache, ViewState (if ASP.NET), etc.).
Then, if the user clears the textbox, capture the empty box before rebinding
the updated data. If the user has done this, let them know the value "X"
cannot be empty with a popup window.

If you have done all of this using drag and drop, you will have to edit some
of the generated code to take control.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
G

Guest

Thanks for tip.

Btw is it possible to insert a null or empty value into the numeric column?
Just like it was before we inserted a number for the first time.

Thanks again.
 

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

Top