Filtering Gridview

M

Mark B

This code works fine to filter a Gridview:

With SqlDataSource3
.FilterExpression = "LanguageText LIKE '%{0}%'"
.FilterParameters.Clear()
.FilterParameters.Add("fp2", TextBox4.Text)
End With



unless the text entered in TextBox4.Text includes a single quote '

Then an error is given:

- 'always
Syntax error: Missing operand after 'always' operator.

- alway's
Syntax error: Missing operand after 's' operator.

- always'
The expression contains an invalid string constant: '.


Suggestions?
 
M

Mark B

Thanks that worked:

With SqlDataSource3
.FilterExpression = "LanguageText LIKE '%{0}%'"
.FilterParameters.Clear()
.FilterParameters.Add("fp2", TextBox4.Text.Replace("'",
"''"))
End With
 
C

Cowboy \(Gregory A. Beamer\)

The single quote is the bane of database programmer's existence. ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top