?
Solved

handle a double variable constructed in vb.net in an sql query

Posted on 2007-04-06
2
Medium Priority
?
234 Views
Last Modified: 2013-11-26
Hi all,

I'm strugling with the following issue:-

want to construct an sql query within a vb.net program.
this query contains a variable which is a double like
Dim MyDouble as Double = 0.75
so the query should become like:-
Dim query as string

query = "Update XYZ where myvariable = '0.75'"

How to construct this and how to prevent that it becomes like

Query =  "Update XYZ where myvariable = '0,75'"    (see the comma in stead of the point)

This is necessary because i want to run
Dim SpToRun As New Data.SqlClient.SqlCommand
            SpToRun.CommandType = CommandType.Text
            SpToRun.CommandText = Query
            SpToRun.Connection = loConnection

and in one way or another the engine  sees the 0,75 as a varchar ...
0
Comment
Question by:aatjan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18865835
use the parameters

Query =  "Update XYZ where myvariable =  @value  "    

Dim SpToRun As New Data.SqlClient.SqlCommand
SpToRun.CommandType = CommandType.Text
SpToRun.CommandText = Query
SpToRun.Connection = loConnection
SpToRun.Parameters.Add("@value", 0.75)

SpToRun.ExecuteNonQuery
0
 
LVL 1

Accepted Solution

by:
dolemitehumantornado earned 1500 total points
ID: 18866016
Hi,

Remove the ' ' from around your 0.75.  That identifies it as a varchar.

query = "Update XYZ where myvariable = 0.75"

0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question