Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
hii

I Have to pass around 80 fields to database which is most of different type.
so in code behind file I want to check the type and and have to convert it to db type as value is accessing from textbox.

so I want to make method in which ill check data where its empty (if empty then send DBNULL.Value)
and if not then convert to datatype which ill pass as argument

Is this possible
how can i achieve it

please help....!!!
Posted
Comments
[no name] 7-Mar-13 9:31am    
"Is this possible", yes it's possible but probably completely unnecessary.
"how can i achieve it", by writing a ton of code that you probably do not need to.
Maybe you should look into parametrized queries and see if that would help you.
sanchu90 7-Mar-13 9:58am    
Okay thn please suggest me some way so that i dont need to do checking 80 times
[no name] 7-Mar-13 9:59am    
If you read my comment, I already did.

1 solution

Why would you want to?
Check for null by all means - it's a good idea to do that anyway.
But if you pass the value as a parameter using the SqlCommand.Parameters.AddWithValue method, you need do no other conversion at all - it will be sorted out for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900