I have a text box and datetime where can i enter an integer . I wish to store this in a SQL Server Database. If i enter then I would store a NULL. However if the text box is left blank, I get an error Input string was not in a correct format. How can I work around this, and get the null into the db?
this Code in method - public void Add_ItemSeasonalPrices(string ItemCode, DateTime FromDate, DateTime ToDate, decimal WholeSaleForFirstUnit, decimal WholeSaleForSecondUnit, decimal WholeSaleForThirdUnit)
-
{
-
DAL.DataAccessLayer DAL = new DAL.DataAccessLayer();
-
DAL.open();
-
SqlParameter[] param = new SqlParameter[22];
-
param[0] = new SqlParameter("@ItemCode", SqlDbType.NVarChar, 25);
-
param[0].Value = ItemCode;
-
-
param[1] = new SqlParameter("@FromDate", SqlDbType.DateTime);
-
param[1].Value = FromDate;
-
-
-
param[2] = new SqlParameter("@ToDate", SqlDbType.DateTime);
-
param[2].Value = ToDate;
-
-
-
param[3] = new SqlParameter("@WholeSaleForFirstUnit", SqlDbType.Decimal);
-
param[3].Value = WholeSaleForFirstUnit;
-
-
-
param[4] = new SqlParameter("@WholeSaleForSecondUnit", SqlDbType.Decimal);
-
param[4].Value = WholeSaleForSecondUnit;
-
-
-
param[5] = new SqlParameter("@WholeSaleForThirdUnit ", SqlDbType.Decimal);
-
param[5].Value = WholeSaleForThirdUnit;
-
DAL.ExecuteCommand("Add_ItemSeasonalPrices", param);
-
DAL.close();
-
}
and this Code in btnSave - Item.Add_ItemSeasonalPrices(txt_ItemCode.Text, Convert.ToDateTime(FromDate.Text), Convert.ToDateTime(ToDate.Text), Convert.ToDecimal(txt_WholeSaleForFirstUnit.Text), Convert.ToDecimal(txt_WholeSaleForSecondUnit.Text),
-
Convert.ToDecimal(txt_WholeSaleForThirdUnit.Text);
0 2613 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Keith |
last post by:
I am Using Dreamweaver MX to create my site and have come accross a problem
no one in the DW groups seems to be able to help with.
When I submit an insert to my SQL database, any form value which...
|
by: Python_it |
last post by:
Python 2.4
MySQL-python.exe-1.2.0.win32-py2.4.zip
How can I insert a NULL value in a table (MySQL-database).
I can't set a var to NULL? Or is there a other possibility?
My var must be variable...
|
by: FatboyCanteen |
last post by:
When I using dataset to append
a null value to the datetime field.
It throw a error -> can not convert db.null to system.date
Can there is any standard to pass a Null value
to the DateTime...
|
by: NuB |
last post by:
I have a sql query that is doing an update of records, how can I add NULL to
the field in the database if the field on my screen is blank?
example:
I have 5 textboxes, and a user can leave some...
|
by: hemant123 |
last post by:
Hi
I Am Trying To Insert Null Value In Oracle Date Column Using Visual Basic 6 Textbox. I Tried Various Options But Unable To Insert. Please Advise Me A Solution.
Thanks In Advance
Hemant
|
by: hemant123 |
last post by:
Hi
I am trying to insert null value in date field using vbasic textbox.I tried various options but failed.Please tell me the solution.
Thanks in advance.
Hemant
|
by: rc |
last post by:
How to insert NULL values in to int field using params.
I'm trying to use pymssql.execute, passing the operation and list of
params. One of the values in the params is a NULL value going to int...
|
by: billa856 |
last post by:
Hi,
I am trying to insert Null value in column(ShipDate) in my table.That column(ShipDate)'s type id date/time and format is short date.
I am using "" to insert Null in that column(ShipDate)...
|
by: RN1 |
last post by:
How do I insert NULL values in a SQL Server DB table in a column whose
datatype is int? This is what I am trying currently (in the
UpdateCommand event function of a DataGrid):
...
|
by: dmorand |
last post by:
I have this query that I'm using in coldfusion:
Insert into ps_manager_employee_ids (manager_emplid,emp_id,last_name,first_name,hire_dt,rehire_dt,emp_status,union_status)
values...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |