I have typically always used one of the VB CType functions (not CType itself
but CInt, CString, etc...) to cast/convert an input value to its proper type
before passing it as a parameter to a SQL stored procedure. I recently came
accross one I did not know how to handle though... TinyInt. I have an SQL
field of type TinyInt which is an 8bit integer. I came accross a ToInt16()
vb function but not one for an 8 bit 'TinyInt'. So I next just went ahead
and tried to submit the value as is to the stored procedure to see if there
would be a problem. The value is a string (from a
dropdownListBox .SelectedItem.T ext). To my suprise there was no error. It
took the value fine. The SQL stored procedure was expecting a TinyInt as
declared in the stored procedure. ??
1) Is there some type of auto-conversion in place? have I been wasting time
and/or slowing performance converting/casting myself all this time?
2) does the SQL stored procedure convert it itself since that is what was
declared within it?
any info would be greatly appreciated. Thanks. 7 1631
SqlParameter.Va lue is of type Object, which suggest that everything is taken
care of internally and casting is indeed not required. Of course, to
confirm this assumption, we get Reflector and look at the disassembled code
for how SqlParameter.se t_Value works.
We see that it calls something called SetTypeInfoFrom ComType which in turn
calls a static function GetMetaType of an internal class named MetaType.
This is the function that seems to be doing all the work..stuff like:
case TypeCode.DBNull :
throw ADP.InvalidData Type(TypeCode.D BNull);
case TypeCode.Boolea n:
return MetaType.metaTy peMap[2];
case TypeCode.Char:
throw ADP.InvalidData Type(TypeCode.C har);
case TypeCode.SByte:
throw ADP.InvalidData Type(TypeCode.S Byte);
case TypeCode.Byte
return MetaType.metaTy peMap[20];
case TypeCode.Int16
return MetaType.metaTy peMap[0x10];
Also, FIY, TinyInt is a value from 0-255, which in .Net maps to a Byte and
not an Int16.
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"djc" <no***@nowhere. com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. . I have typically always used one of the VB CType functions (not CType
itself but CInt, CString, etc...) to cast/convert an input value to its proper
type before passing it as a parameter to a SQL stored procedure. I recently
came accross one I did not know how to handle though... TinyInt. I have an SQL field of type TinyInt which is an 8bit integer. I came accross a ToInt16() vb function but not one for an 8 bit 'TinyInt'. So I next just went ahead and tried to submit the value as is to the stored procedure to see if
there would be a problem. The value is a string (from a dropdownListBox .SelectedItem.T ext). To my suprise there was no error. It took the value fine. The SQL stored procedure was expecting a TinyInt as declared in the stored procedure. ??
1) Is there some type of auto-conversion in place? have I been wasting
time and/or slowing performance converting/casting myself all this time?
2) does the SQL stored procedure convert it itself since that is what was declared within it?
any info would be greatly appreciated. Thanks.
the sql sp declares the datatype. when you call the client libary, you pass
an object and tell the client lib the actual datatype of your data. the
client lib will then convert the datatype to the matching sqldatatype, and
pass sql datatype to the sqlserver. the sqlserver than converts the passed
sql datatype to the sp dataype if it can. see the sql Convert function doc's
to see the supported conversions.
-- bruce (sqlwork.com)
"djc" <no***@nowhere. com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
| I have typically always used one of the VB CType functions (not CType
itself
| but CInt, CString, etc...) to cast/convert an input value to its proper
type
| before passing it as a parameter to a SQL stored procedure. I recently
came
| accross one I did not know how to handle though... TinyInt. I have an SQL
| field of type TinyInt which is an 8bit integer. I came accross a ToInt16()
| vb function but not one for an 8 bit 'TinyInt'. So I next just went ahead
| and tried to submit the value as is to the stored procedure to see if
there
| would be a problem. The value is a string (from a
| dropdownListBox .SelectedItem.T ext). To my suprise there was no error. It
| took the value fine. The SQL stored procedure was expecting a TinyInt as
| declared in the stored procedure. ??
|
| 1) Is there some type of auto-conversion in place? have I been wasting
time
| and/or slowing performance converting/casting myself all this time?
|
| 2) does the SQL stored procedure convert it itself since that is what was
| declared within it?
|
| any info would be greatly appreciated. Thanks.
|
|
My newsreader shows my reply to this as deleted...so I'll try again...sorry
for the possible double post:
SqlParameter.Va lue is of type Object, which suggest that everything is taken
care of internally and casting is indeed not required. Of course, to
confirm this assumption, we get Reflector and look at the disassembled code
for how SqlParameter.se t_Value works.
We see that it calls something called SetTypeInfoFrom ComType which in turn
calls a static function GetMetaType of an internal class named MetaType.
This is the function that seems to be doing all the work..stuff like:
case TypeCode.DBNull :
throw ADP.InvalidData Type(TypeCode.D BNull);
case TypeCode.Boolea n:
return MetaType.metaTy peMap[2];
case TypeCode.Char:
throw ADP.InvalidData Type(TypeCode.C har);
case TypeCode.SByte:
throw ADP.InvalidData Type(TypeCode.S Byte);
case TypeCode.Byte
return MetaType.metaTy peMap[20];
case TypeCode.Int16
return MetaType.metaTy peMap[0x10];
Also, FIY, TinyInt is a value from 0-255, which in .Net maps to a Byte and
not an Int16.
--
MY ASP.Net tutorials http://www.openmymind.net/
"djc" <no***@nowhere. com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. . I have typically always used one of the VB CType functions (not CType
itself but CInt, CString, etc...) to cast/convert an input value to its proper
type before passing it as a parameter to a SQL stored procedure. I recently
came accross one I did not know how to handle though... TinyInt. I have an SQL field of type TinyInt which is an 8bit integer. I came accross a ToInt16() vb function but not one for an 8 bit 'TinyInt'. So I next just went ahead and tried to submit the value as is to the stored procedure to see if
there would be a problem. The value is a string (from a dropdownListBox .SelectedItem.T ext). To my suprise there was no error. It took the value fine. The SQL stored procedure was expecting a TinyInt as declared in the stored procedure. ??
1) Is there some type of auto-conversion in place? have I been wasting
time and/or slowing performance converting/casting myself all this time?
2) does the SQL stored procedure convert it itself since that is what was declared within it?
any info would be greatly appreciated. Thanks.
Thank you for the excellently explained answer. I appreciate it greatly.
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OM******** ******@TK2MSFTN GP10.phx.gbl... SqlParameter.Va lue is of type Object, which suggest that everything is
taken care of internally and casting is indeed not required. Of course, to confirm this assumption, we get Reflector and look at the disassembled
code for how SqlParameter.se t_Value works.
We see that it calls something called SetTypeInfoFrom ComType which in
turn calls a static function GetMetaType of an internal class named MetaType. This is the function that seems to be doing all the work..stuff like:
case TypeCode.DBNull : throw ADP.InvalidData Type(TypeCode.D BNull); case TypeCode.Boolea n: return MetaType.metaTy peMap[2]; case TypeCode.Char: throw ADP.InvalidData Type(TypeCode.C har); case TypeCode.SByte: throw ADP.InvalidData Type(TypeCode.S Byte); case TypeCode.Byte return MetaType.metaTy peMap[20]; case TypeCode.Int16 return MetaType.metaTy peMap[0x10];
Also, FIY, TinyInt is a value from 0-255, which in .Net maps to a Byte and not an Int16.
Karl -- MY ASP.Net tutorials http://www.openmymind.net/
"djc" <no***@nowhere. com> wrote in message news:%2******** *******@TK2MSFT NGP11.phx.gbl.. . I have typically always used one of the VB CType functions (not CType itself but CInt, CString, etc...) to cast/convert an input value to its proper type before passing it as a parameter to a SQL stored procedure. I recently came accross one I did not know how to handle though... TinyInt. I have an
SQL field of type TinyInt which is an 8bit integer. I came accross a
ToInt16() vb function but not one for an 8 bit 'TinyInt'. So I next just went
ahead and tried to submit the value as is to the stored procedure to see if there would be a problem. The value is a string (from a dropdownListBox .SelectedItem.T ext). To my suprise there was no error. It took the value fine. The SQL stored procedure was expecting a TinyInt as declared in the stored procedure. ??
1) Is there some type of auto-conversion in place? have I been wasting time and/or slowing performance converting/casting myself all this time?
2) does the SQL stored procedure convert it itself since that is what
was declared within it?
any info would be greatly appreciated. Thanks.
My newsreader shows both posts... but since your original is showing deleted
to you I am thanking you in both places to make sure you get the proper
thanks. Thanks!
Thank you for the excellently explained answer. I appreciate it greatly.
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:O%******** *******@TK2MSFT NGP11.phx.gbl.. . My newsreader shows my reply to this as deleted...so I'll try
again...sorry for the possible double post:
SqlParameter.Va lue is of type Object, which suggest that everything is
taken care of internally and casting is indeed not required. Of course, to confirm this assumption, we get Reflector and look at the disassembled
code for how SqlParameter.se t_Value works.
We see that it calls something called SetTypeInfoFrom ComType which in
turn calls a static function GetMetaType of an internal class named MetaType. This is the function that seems to be doing all the work..stuff like:
case TypeCode.DBNull : throw ADP.InvalidData Type(TypeCode.D BNull); case TypeCode.Boolea n: return MetaType.metaTy peMap[2]; case TypeCode.Char: throw ADP.InvalidData Type(TypeCode.C har); case TypeCode.SByte: throw ADP.InvalidData Type(TypeCode.S Byte); case TypeCode.Byte return MetaType.metaTy peMap[20]; case TypeCode.Int16 return MetaType.metaTy peMap[0x10];
Also, FIY, TinyInt is a value from 0-255, which in .Net maps to a Byte and not an Int16.
-- MY ASP.Net tutorials http://www.openmymind.net/
"djc" <no***@nowhere. com> wrote in message news:%2******** *******@TK2MSFT NGP11.phx.gbl.. . I have typically always used one of the VB CType functions (not CType itself but CInt, CString, etc...) to cast/convert an input value to its proper type before passing it as a parameter to a SQL stored procedure. I recently came accross one I did not know how to handle though... TinyInt. I have an
SQL field of type TinyInt which is an 8bit integer. I came accross a
ToInt16() vb function but not one for an 8 bit 'TinyInt'. So I next just went
ahead and tried to submit the value as is to the stored procedure to see if there would be a problem. The value is a string (from a dropdownListBox .SelectedItem.T ext). To my suprise there was no error. It took the value fine. The SQL stored procedure was expecting a TinyInt as declared in the stored procedure. ??
1) Is there some type of auto-conversion in place? have I been wasting time and/or slowing performance converting/casting myself all this time?
2) does the SQL stored procedure convert it itself since that is what
was declared within it?
any info would be greatly appreciated. Thanks.
great! thank you!
"bruce barker" <no***********@ safeco.com> wrote in message
news:ub******** ******@TK2MSFTN GP09.phx.gbl... the sql sp declares the datatype. when you call the client libary, you
pass an object and tell the client lib the actual datatype of your data. the client lib will then convert the datatype to the matching sqldatatype, and pass sql datatype to the sqlserver. the sqlserver than converts the passed sql datatype to the sp dataype if it can. see the sql Convert function
doc's to see the supported conversions.
-- bruce (sqlwork.com)
"djc" <no***@nowhere. com> wrote in message news:%2******** *******@TK2MSFT NGP11.phx.gbl.. . | I have typically always used one of the VB CType functions (not CType itself | but CInt, CString, etc...) to cast/convert an input value to its proper type | before passing it as a parameter to a SQL stored procedure. I recently came | accross one I did not know how to handle though... TinyInt. I have an
SQL | field of type TinyInt which is an 8bit integer. I came accross a
ToInt16() | vb function but not one for an 8 bit 'TinyInt'. So I next just went
ahead | and tried to submit the value as is to the stored procedure to see if there | would be a problem. The value is a string (from a | dropdownListBox .SelectedItem.T ext). To my suprise there was no error. It | took the value fine. The SQL stored procedure was expecting a TinyInt as | declared in the stored procedure. ?? | | 1) Is there some type of auto-conversion in place? have I been wasting time | and/or slowing performance converting/casting myself all this time? | | 2) does the SQL stored procedure convert it itself since that is what
was | declared within it? | | any info would be greatly appreciated. Thanks. | |
I know this is an old and dormant thread, but can anyone tell me where the equivalences between SQL data types (int, datetime, varchar, nvarchar, text, etc.) and the ASP.NET parameter types (int32, String, etc.) are documented?
TIA.
-- Ned
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: matt melton |
last post by:
Hi there,
I am trying to write a method that accepts an array of any primitive
type and will return the same array without copying memory as an array
of bytes.
ie. I'd like to be able to do something like:
char chars = "Hello!";
byte bytes = (byte) chars;
|
by: Kent Lewandowski |
last post by:
Hi,
I saw this post from 3 years ago regarding converting DOUBLE values to
CHAR in ibm DB2. Now I'm having the same problem. No real solution
was posted to that old thread. Has anyone got more information how I
avoid the scientific notation when I use the CHAR() function to
convert a DOUBLE or FLOAT ? What I want is "MagicFunction" in the
following pseudocode:
myVarchar = MagicFunction(123.0003);
|
by: Frazer |
last post by:
hi,
I am confused when to use (int) and when to use Convert.toint32..
eg here
string s= "1";
int j = (int) s; //this gives me an error and i have to use convert.toint32.
why is that so and how do i know when to use which.
thnx
|
by: gg9h0st |
last post by:
i'm a newbie studying php.
i was into array part on tutorial and it says
i'll get an array having keys that from member variable's name
by converting an object to array.
i guessed "i can get public members but not protected, private, static
members"
|
by: TheLongshot |
last post by:
Ok, let's try this again.
I have an ASP.NET 1.1 application that I'm working to convert to 2.0,
but I've run into a snag.
The problem is with this line:
return
(IDataProviderBase)(((ConstructorInfo)cache).Invoke(null)
);
| |
by: nanodust |
last post by:
hello all
i am relatively new to python, catching on, but getting stuck on
simple thing:
i have two string bytes i need to push into a single (short) int, like
so in c:
temp = strBuf;
|
by: Sean Farrow |
last post by:
Hi:
What is best and safest way of converting a char* to a const char *? Can I
use const_cast?
Cheers
Sean.
|
by: Chad |
last post by:
Keith made the following comment
" You can convert an int*, or an int**, or an int***, or ... to void*
without loss of information -- except that you lose the type
information, which you have to carefully keep track of yourself. "
How would you track the type infornation?
|
by: Slain |
last post by:
I need to convert a an array to a multidimensional one. Since I need
to wrok with existing code, I need to modify a declaration which looks
like this
In the .h file
int *x;
in a initialize function:
x = new int;
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |