datatypes

MSSQL Assemblies and SQLBinary DataType

I have a c# assembly which takes in a SQLBinary variable to decrypt... [SqlProcedure(Name="Decrypt")] public static SqlInt32 Decrypt(SqlBinary toDecrypt) { return runQuery(toDecrypt); } // decrypt or encrypt is determined based on the datatype of argValue private static SqlInt32 runQuery(object argValue) { // create connection ...

C# doubt, finding the datatype

I have the following variables: string str1 = "1"; string str2 = "asd"; string str3 = "3.5"; string str4 = "a"; Now I need to find the data type of each string i.e. the data type to which it can be converted if quotes are removed. Here is what I would like each variable to convert to: str1 - integer str2 - string str3 - doubl...

NHibernate DataTypes - NoYes Boolean

What is the best way to get the reverse behavior of the YesNo Boolean type in NHibernate mapping? I want 'Y' to mean false and 'N' to mean true. Is there a NoYes type? Do you write a custom type? something really easy? This issue of needing to reverse the Boolean exists on at least one field on over 40 tables. Trying to adapt to a leg...

Custom Control with Data Type property Issue

I'm building a custom user control. One of the properties must allow the end user to select the numeric data type such as int, short, long, double.... I'm having a problem figuring out what to use as an internal property type, so that when the user selects the DataType option in the property box it will give them a drop down list of...

De facto list of primitive types usable in C++

If, for example, you're going to write a variant type class, you will naturally need identification of what type an instance of that class is carrying. I'm wondering if anyone knows of any official or semi-official (de-facto?) reference of all primitive datatypes one would possibly be interested in? Only primitives, and no need for abs...

What is the fastest way to read a large number of small files into memory ?

I need to read ~50 files on every server start and place each text file's representation into memory. Each text file will have its own string (which is the best type to use for the string holder?). What is the fastest way to read the files into memory, and what is the best data structure/type to hold the text in so that I can manipulate...

GetDiskFreeSpaceEx reports wrong number of free bytes

__int64 i64FreeBytes unsigned __int64 lpFreeBytesAvailableToCaller, lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes; // variables used to obtain // the free space on the drive GetDiskFreeSpaceEx (Manager.capDir, (PULARGE_INTEGER)&lpFreeBytesAvailableToCaller, ...

In SQL how can I convert a money datatype to a decimal?

I want to convert a money datatype to a decimal, because I want to record the results to 8 decimal places. For example, in a currency rate table I see the rate stored as 2871047428.20 as a money datatype; using Microsoft SQL Management Studio, I want to divide that by 10000000 in order to achieve the result 287.10474282; however the res...

Data Type of a field

Hey guys and gals, I have a field in a table that I will be storing different kinds of data in it, Like: X-Large, Medium, Small....or I might store: 22-March-2009, 1 Year, 2 Years, 3 Years...or 06Months, 12 Months, 1 Year, or I might store: "33-36", "37-40"...and that data is not fixed, i might need in the future to add new categories......

Automatic type conversion in Visual Basic 6.0

When we convert a float to integer in visual basic 6.0, how does it round off the fractional part? I am talkin about the automatic type conversion. If we assign like Dim i as Integer i=5.5 msgbox i What will it print? 5 or 6 ?? I was getting "5" a couple of months before. One day it started giving me 6! Any idea whats goin wrong? D...

Do you lose precision when converting from real to money datatype in sql server?

I have a table with datafields in real datatype. Do you lose precision when converting to money or decimal datatype? ...

C++ ULONG definitions to vb.net or c# equivalent?

Trying to use a call recording API using sockets. We have the API documentation but the samples are all in C++. How would I declare the following in vb.net or c#??? #define SIF_GENERAL 0x08000000 #define SIF_CONFIGURATION 0x08010000 #define SIF_ARCHIVE 0x08020000 #define SIF_SEARCH 0x08030000 #define SIF_REPLAY 0x08040000 #define SIF_S...

ADO.Net DataType of column of DataTable issue

Hello everyone, My question is how to assign the DataType value for columns of special SQL Types like, uniqueidentifier/nvarchar/datetime/varbinary(max) -- I did not find a mapping between .Net data type and such 4 types of SQL column data type? Here is a sample, which shows we need to assign the DataType (this sample maps .Net type to...

Why is maximum length of varchar less than 8,000 bytes?

So I have a stored procedure in a SQLServer 2005 database, which retrieves data from a table, format the data as a string and put it into a varchar(max) output variable. However, I notice that although len(s) reports the string to be > 8,000, the actual string I receive (via SQLServer output window) is always truncated to < 8,000 bytes....

Best way to store UInt32 in Sql Server

Hello, I'm working on an application that uses a third-party component, and this component returns a value that is of type UInt32. I need to store this UInt32 in a Sql Server table. I was thinking about just use a simple int column and insert the value like this: int value = (int)(cs - int.MaxValue); But I'm not sure if this is the b...

SQL DataType - How to store a year?

I need to insert a year(eg:1988 ,1990 etc) in a database. When I used Date or Datetime data type, it is showing errors. Which datatype should I use. ...

Can other datatypes than Strings be potentially harmful if obtained from external sources?

It's a well known truth, that you don't can trust user inputs. These inputs can be even an security-problem, if they are used unfiltered. XSS and SQL-injections are possible problems coming from using unfiltered user-input (or input, that can be changed by the user). To avoid such problems, you have to control all strings, that can be i...

Theory of storing a number and text in same SQL field

I have a three tables Results: TestID TestCode Value Tests: TestID TestType SysCodeID SystemCodes SysCodeID ParentSysCodeID Description The question I have is for when the user is entering data into the results table. The formatting code when the row gets the focus changes the value field to a dropdown combobox if the testCode is of...

Initializing PODs in C# - best practice

As far as I know[*], C# defaults the plain-old-data-types (int, float, bool, etc) to sensible values. int a, float b, and bool c take on the values 0, 0.0f, and false, respectively. Assuming this is so: Should I explicitly give my variables values of 0, 0.0f, and false for clarity, or should I leave the values implicit, thus reducing ...

Using a UUID as a Database Primary Key, Java type is a byte[]

Are there any issues with using a byte[] as a primary key in a JPA Entity? I want to use a UUID as my primary key, but stored as a string I feel it will be too large. I was thinking of doing something like this to store the ID as a byte[] and set it as my Entity's ID: public static byte[] byteArray(UUID uuid) { long lsb = uu...