Click here to Skip to main content
14,026,083 members
Rate this:
 
Please Sign up or sign in to 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
NotPolitcallyCorrect 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
NotPolitcallyCorrect 7-Mar-13 9:59am
   
If you read my comment, I already did.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190419.4 | Last Updated 7 Mar 2013
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100