473,387 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Formatting a variable for a WHERE statement

I have a variable string "myvar" and I need to pass it to the WHERE clause of
a SELCET statement I have tried myvar.ToString(), Cint, parse and convert.

The Select statement works fine when I pass a value manually eg WHERE mycust
= "50".

Any ideas?

Thanks, Justin.
Nov 19 '05 #1
1 1104
Justin,

What is the type of mycust column? If it is integer, the where clause should
look like
where mycust = 50
and it can be made by expression
String.Format ("where mycust ={0}", myvar);
If it is string, and your database accept single quote string delimiter like
where mycust = '50'
it can be made by expression
String.Format ("where mycust ='{0}'", myvar);
If double quote delimiter has to be used, use
String.Format ("where mycust =\"{0}\"", myvar);

Eliyahu

"Justin" <Ju****@discussions.microsoft.com> wrote in message
news:1D**********************************@microsof t.com...
I have a variable string "myvar" and I need to pass it to the WHERE clause of a SELCET statement I have tried myvar.ToString(), Cint, parse and convert.

The Select statement works fine when I pass a value manually eg WHERE mycust = "50".

Any ideas?

Thanks, Justin.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: David | last post by:
Hi, I've had a search through google but couldn't really find the answer I was looking for.I'm new to PHP, so please take it <relatively> easy. I've created a script which runs some SNMP...
5
by: da Vinci | last post by:
Hello, I have a question regarding how to format input. I am at the beginners level. Basically, I am reading in a single character from the keyboard using cin and I want to ensure that it is...
2
by: Mark | last post by:
I have an Access 2000 database that pulls a file in everyday via the TransferText method. The file is named "psjrnl 25-Sep-2003.txt" (the 25-Sep-2003 will change and have the current days date). My...
3
by: Chuck Reed | last post by:
I am working on a sales report where I show weekly sales by category for each of the 52 weeks in the year. Each record in my table/report has the 52 weeks of sales in it. I want to highlight to top...
10
by: Coleen | last post by:
Hi all :-) I have a weird formatting problem with an HTML table that I am populating using VB.Net and HTML. Here is the snippet of code for the cell I'm trying to format: Dim...
25
by: mdh | last post by:
Hi Group, Not looking for an answer, but more of an explanation. Thinking back to those heady days when you had the time to do them, may I ask this. Exercise 1-22 asks for a program to "fold"...
2
by: Jim | last post by:
Hi All, I would appreciate a pointer on this problem, if you please. I am writing a 'tell a friend' page for my www site. Essentially, the user opens the page, fills out a form, click submit,...
6
by: Tomasz J | last post by:
Hello developers, I bind my TextBox control specyfying a format stored in my application global ApplicationContext object - it has a static string CurrencyFormat property. The problem - this...
30
by: Ivan Reborin | last post by:
Hello everyone, I was wondering if anyone here has a moment of time to help me with 2 things that have been bugging me. 1. Multi dimensional arrays - how do you load them in python For...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.