Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
rtutus
Aged Yak Warrior
522 Posts |
Posted - 2006-06-25 : 00:47:40
|
1/ When my textbox is empty, doing:pm=Mysqlcommand.parameters.add(new sqlparameter("@Address",sqldbtype.char,50))pm.value=Mytextbox.textsends a string with empty spaces to my table in SQL server.The way I avoid that I do:if Mytextbox.text=string.empty then pm.value=sqlstring.nullelse pm.value=Mytextbox.textend ifMy Question: I want to do that automatically with only one instruction and without doing If...then..else.... 2/ How to cast string variables to sqlstring like from MyTextBox.text to a sqlstring type3/ Sometimes, my object : Myobject is not set to an instance, but I still want to assign it to my parameterpm.value=MyObject.propertyIs that possible4/ Do u know hoe to cast other types: Integer to SqlInt64 and vice versa; Thanks a lot |
|
JBelthoff
Posting Yak Master
173 Posts |
Posted - 2006-06-26 : 11:09:08
|
1. You are going to have to do the If..Then either in Asp.Net or in the Database.If Mytextbox.text.trim = "" Then pm.value = dbNullElse pm.value = Mytextbox.text.trimEnd If 2. Use the ADO.Net Command Object.3. If your object is not set to an instance, your code will more than likely fail.4. Use the ADO.Net Command Object.JBelthoff• Hosts Station is a Professional Asp Hosting Provider• Position SEO can provide your company with SEO Services at an affordable price› As far as myself... I do this for fun! |
 |
|
|
|
|