Last post Dec 29, 2010 04:52 AM by singhmanish_888
Dec 29, 2010 02:11 AM|q8_dreamy|LINK
Hiiii, I have form of textboxes and drop down lists and button. when I click button I should insert values of these controls into oracle db.
these controls are inside ajax tabs, no update panel, my silly problem is when I click submit button and all textboxes have values then the
form works fine and data will be inserted in the db but there are just 3 of these textboxes when I leave on of them blank I got the following error
I checked my db I allowed null to these values and when I insert using oracle developer and keep null to these values it works!!! I know it is something silly
because I tried to change textboxes 100 times it worked fine at the begining but when I change the place of the textbox the error comes again!!!!!!!
here is my code:
Me.ds_Con_Insert.InsertCommand = "INSERT INTO CONTRACT (CODE, REQ_NO, CON_NO, COST, START_DATE, END_DATE, TECH_SPEC) VALUES ('" & Me.Txt_Code.Text & "','" & Me.Txt_ReqNo.Text & "','" & Me.Txt_Con.Text & "','" & Me.txt_c_2.Text & "','" &
Me.Txt_SDate.Text & "','" & Me.Txt_EDate.Text & "','" & Me.Txt_C_Tech.Text & "')"
the three values that won't work are cost (number), start date (date) and end date (date)
Dec 29, 2010 02:33 AM|subhmajumdar|LINK
Can you try with by passing DBNull.Value
to the database when a textbox is empty?
Dec 29, 2010 02:44 AM|singhmanish_888|LINK
I don't think its an issue of passing null values.Debug your code and check values of cost (number), start date (date) and end date(date) you are passing through code.Probably it might be a datatype mismatch or you are passing dates in wrong format.
Copy you InsertCommand string and try to run the same in Oracle(Toad or SQL*) and then check for the error.
Dec 29, 2010 02:46 AM|q8_dreamy|LINK
which means if statement checks if one of them is null or not!! doesn't make sence
I tried to replace me.txt_c_2.text with " " and it worked fine!!! The null value was entered successfully!! GOD
What is the problem
Dec 29, 2010 02:49 AM|q8_dreamy|LINK
Iam using ajax calender for dates textboxes and Iam entering number in cost textbox!!!!
Dec 29, 2010 04:52 AM|singhmanish_888|LINK
You can write like this
You can check before assigning values to the query
String.IsNullOrEmpty(Me.txt_c_2.Text) ? string.empty : Me.txt_c_2.Text