1 Replies - 5923 Views - Last Post: 18 June 2012 - 05:44 AM Rate Topic: -----

#1 ricemaster5000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-June 12

MultiLine Datagrid view query

Posted 12 June 2012 - 08:39 PM


I am creating an asp.net website using VB with a Datagrid view that links to a SQL Database. The databse Includes a number column and a description column. I've created a Searchbox that changes the Select Statement of the query of the Datagrid view to show what the user has posted in the textbox, when the user presses the search button.
Dim searchword As String
searchword = "select * from Parts where (PartNumber Like '%" + TextBox1.Text.ToString() + "%')"
SqlDataSource1.SelectCommand = searchword

This Querys out the table to show only what the user has posted in the text box. What I want to do is change the textbox to a multiline textbox so users can dump multiple numbers into it at once, and get back all matching numbers. How would I go about doing this would it be using this same method?


Is This A Good Question/Topic? 0
  • +

Replies To: MultiLine Datagrid view query

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1532
  • View blog
  • Posts: 5,969
  • Joined: 21-March 08

Re: MultiLine Datagrid view query

Posted 18 June 2012 - 05:44 AM

To make the TextBox mutliline, simply change the TestMode property.

Your current code is opening you up to SQL Injection attacks. You should use a parameterized query to do this.

As for how to do a parameterized query with the LIKE or IN command, this should help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1