1 Replies - 1298 Views - Last Post: 07 July 2011 - 07:51 AM Rate Topic: -----

#1 Dannrafer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-July 11

search database using textbox

Posted 07 July 2011 - 07:40 AM

I want to search my database using textbox hers my code:
I did not get error with this code but it didnt search anything on my databse..
 Private cs As New SqlConnection("Data Source=DANN-D3CCEAB190\SQLEXPRESS;Initial Catalog=StudentGradeCompilation;Integrated Security=True")
   
    Private da As New SqlDataAdapter("SELECT Studentname, Studentnocode, [Print] FROM Table_1 WHERE Studentnocode LIKE '%Maintext.text' ", cs)


    Private ds As New DataSet

    Private cmb As New SqlCommandBuilder(da)
    Public BindingSource1 As New BindingSource()


This post has been edited by Dannrafer: 07 July 2011 - 07:46 AM


Is This A Good Question/Topic? 0
  • +

Replies To: search database using textbox

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 6469
  • View blog
  • Posts: 23,512
  • Joined: 12-June 08

Re: search database using textbox

Posted 07 July 2011 - 07:51 AM

Awesome! Are you having problems with it? Is the code not working as expected? If so how is it working and how should it be working? Is there an exception? If so what is the exception and what line is it occurring on?

Just by looking at it I can tell your SQL statement is flawed. You need to get your maintext to APPEND to the string and not be just characters in a string!

" SELECT Studentname, Studentnocode, [Print] FROM Table_1 WHERE Studentnocode LIKE '%" + Maintext.text + "%'"


I am not sure if the code is outside of the chunk you gave us, but I do hope you are executing that query!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1