Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie SQL question, double data type

Status
Not open for further replies.

magnus2

Programmer
Mar 8, 2004
23
SE
Hi! I send a double variable from VB.NET code to a SQL database on my own computer. There seems to be a problem when the double contains a lots of decimals. This prevents the variable from being sent. Is it possible to change the allocated memory space for the double in the database or do I have to truncate the variable in VB.NET? Any suggestions? Is this the right forum? Hope so :) Kind regards /Magnus
 
What is the datatype of the field in SQL Server? SQL server does not have a double data type, so your problem is probably inthe conversion. How to fix may depend on the data type you are trying to insert the value into.

Questions about posting. See faq183-874
 
it may be the data type is to small of the number you want to recieve? check SQL BOL (books online) data types for decimal, numeric, real and float.

One of them should be able to hold the data. A double cannot be stored in any type of integer (bigint, int, smallint, tinyint). These are whole numbers only.

Jason Meckley
Database Analyst
WITF
 
Hi! There's only room for one decimal though it says 'data type double' in the SQL table. I don't use a server, only a database on my computer. I will try your suggestions. Thank you!
 
That is I can enter a number with more decimals directly in the table, but it doesn't seem tom be possible to send it from Visual Basic. Hmm...strange...
 
Hm, it works when I do it like this and put 'signs around the double variable:

StrSQL = "INSERT INTO Table1 (A, B)" & _
" VALUES (" & integerA & ", '" & doubleB & "')"

The 'signs seems to be a somewhat magical solution. Should I always have ' around my variables?

Maybe this is a VB question.

Kind regards!
 
if you put quotes around your value, then you are telling the sql statement it is a string. All strings must be sorrunded by quotes. numbers does not have to be.

Jason Meckley
Database Analyst
WITF
 
SQL Server does not have a data type double, what database are you using as your backend?

Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top