473,395 Members | 1,623 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,395 software developers and data experts.

Problem with Select Command

Hi all,
I need some help with a simple select query using MS SQL Server 2005.
The problem I am having is due to the contents of the table, it can
contain names which use punctuation marks such as:

S'Algar
Olhos D'Agua
Praia D'Oura
etc.etc
This is breaking my SQL Queries. I select the data using

Dim command As New SqlCommand("Select * from Navigation where
Keyword='" & Index & "'", connection)
and simply read the data returned by the query, into a dataset.
I'd be grateful for any help offered

Kind Regards

Nov 9 '06 #1
1 1143
Parameterize your queries..it'll be safer and likely fix your bug.

"SELECT * FROM Navigation WHERE Keyword = @Index"
command.Parameters.Add("@Index", SqlDbType.VarChar, 128).Value = index
the VarChar and 128 parts I made up, you'll need to change the to whatever
actual type/length you want.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
<mi*********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hi all,
I need some help with a simple select query using MS SQL Server 2005.
The problem I am having is due to the contents of the table, it can
contain names which use punctuation marks such as:

S'Algar
Olhos D'Agua
Praia D'Oura
etc.etc
This is breaking my SQL Queries. I select the data using

Dim command As New SqlCommand("Select * from Navigation where
Keyword='" & Index & "'", connection)
and simply read the data returned by the query, into a dataset.
I'd be grateful for any help offered

Kind Regards

Nov 9 '06 #2

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

Similar topics

1
by: Snick | last post by:
Hello, I've been going through the DB2 application development manuals and have no idea what I'm doing wrong with my UDF. Basically, I created a C++ library that compares 2 strings and returns...
5
by: Timppa | last post by:
Hi, Could anyone help me with my problem ? Environment: Access 2000 and Sql Server 2000. I have a stored procedure as follows: DROP table1 SELECT alias1.field1,alias2.field2,table2.field6...
4
by: Beringer | last post by:
Hello, I am trying to make a query against an Access Database File using OleDb part of the framework. I created an SQL Query string using Access and it will execute the query successfully in...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
1
by: kimso.zhao | last post by:
Hi all, When I tried reading user command from console, I use "select" to wait for user input in order to improve efficiency. But when it comes to dealing with user pasting a command, there is a...
8
by: Ian Mackenzie | last post by:
Hi Guys I am VERY new to DB2 and have created a workingdays function to return the working days between 2 dates, but I get some compiler errors when running it: CREATE FUNCTION WORKINGDAYS...
2
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import...
0
by: ipoxygen | last post by:
Hi, I do have 6 identical tables on six different databases (same server). I would like to merge them into one single table for reporting purposes. For the majority of the table it does work...
8
by: Martin Z | last post by:
INSERT INTO dbo.Transmission (TransmissionDate, TransmissionDirection, Filename, TransmittedData) VALUES (@TransmissionDate,@TransmissionDirection,@Filename,@TransmittedData); SELECT @retVal =...
12
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.