Menu
Home
Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Database
MS Access
search for sting in database
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="hometech" data-source="post: 159998" data-attributes="member: 40416"><p>Hello Guys,</p><p></p><p>I have a database that contains a lot of text (like a page full). I want to be able to search the database for a particular string of text or word in the database. i have a textbox on my form where the user is going to enter the input text/ string.</p><p></p><p>For example: i have this text in the database</p><p></p><p><!-- start slipsum code --></p><p></p><p>Now that we know who you are, I know who I am. I'm not a mistake! It all makes sense! In a comic, you know how you can tell who the arch-villain's going to be? He's the exact opposite of the hero. And most times they're friends, like you and me! I should've known way back when... You know why, David? Because of the kids. They called me Mr Glass.</p><p>Normally, both your asses would be dead as ****ing fried chicken, but you happen to pull this **** while I'm in a transitional period so I don't wanna kill you, I wanna help you. But I can't give you this case, it don't belong to me. Besides, I've already been through too much **** this morning over this case to <strong>hand it over</strong> to your dumb ass.</p><p>Now that there is the Tec-9, a crappy spray gun from South Miami. This gun is advertised as the most popular gun in American crime. Do you believe that ****? It actually says that in the little book that comes with it: the most popular gun in American crime. Like they're actually proud of that ****. </p><p></p><p></p><p>I want to be able to search for the text "hand it over" that will be entered in a the textbox on the form and display the search results in a list box in this format</p><p></p><p>it takes some text to the left and right of the search string eg. <u>case to</u> <strong>hand it over</strong> <u>to your</u></p><p></p><p>I keep getting this error message: Expected query name after EXECUTE.</p><p></p><p>Please any suggestions on how to go about this?</p><p></p><p>Thanks</p><p></p><p>[CODE]</p><p>Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click</p><p></p><p> Dim feed As String</p><p></p><p> feed = TextBox2.Text</p><p> Dim con As OleDbConnection = New OleDbConnection()</p><p></p><p> con.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath & "\scrollDatabase.mdb"</p><p> Dim sqlCmd As OleDbCommand = New System.Data.OleDb.OleDbCommand()</p><p></p><p> sqlCmd.CommandType = CommandType.StoredProcedure</p><p> sqlCmd.CommandText = "SELECT * [Scroll] tablename WHERE Scroll LIKE '*" & Trim(TextBox2.Text) & "*'"</p><p> sqlCmd.Connection = con</p><p></p><p> con.Open()</p><p></p><p> Dim reader As OleDbDataReader</p><p></p><p> reader = sqlCmd.ExecuteReader()</p><p></p><p> If reader.HasRows Then</p><p> While reader.Read()</p><p> Console.WriteLine(reader("Scroll")) 'output specific column</p><p> End While</p><p> End If</p><p></p><p> Console.ReadLine()</p><p> End Sub</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="hometech, post: 159998, member: 40416"] Hello Guys, I have a database that contains a lot of text (like a page full). I want to be able to search the database for a particular string of text or word in the database. i have a textbox on my form where the user is going to enter the input text/ string. For example: i have this text in the database <!-- start slipsum code --> Now that we know who you are, I know who I am. I'm not a mistake! It all makes sense! In a comic, you know how you can tell who the arch-villain's going to be? He's the exact opposite of the hero. And most times they're friends, like you and me! I should've known way back when... You know why, David? Because of the kids. They called me Mr Glass. Normally, both your asses would be dead as ****ing fried chicken, but you happen to pull this **** while I'm in a transitional period so I don't wanna kill you, I wanna help you. But I can't give you this case, it don't belong to me. Besides, I've already been through too much **** this morning over this case to [B]hand it over[/B] to your dumb ass. Now that there is the Tec-9, a crappy spray gun from South Miami. This gun is advertised as the most popular gun in American crime. Do you believe that ****? It actually says that in the little book that comes with it: the most popular gun in American crime. Like they're actually proud of that ****. I want to be able to search for the text "hand it over" that will be entered in a the textbox on the form and display the search results in a list box in this format it takes some text to the left and right of the search string eg. [U]case to[/U] [B]hand it over[/B] [U]to your[/U] I keep getting this error message: Expected query name after EXECUTE. Please any suggestions on how to go about this? Thanks [CODE] Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim feed As String feed = TextBox2.Text Dim con As OleDbConnection = New OleDbConnection() con.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath & "\scrollDatabase.mdb" Dim sqlCmd As OleDbCommand = New System.Data.OleDb.OleDbCommand() sqlCmd.CommandType = CommandType.StoredProcedure sqlCmd.CommandText = "SELECT * [Scroll] tablename WHERE Scroll LIKE '*" & Trim(TextBox2.Text) & "*'" sqlCmd.Connection = con con.Open() Dim reader As OleDbDataReader reader = sqlCmd.ExecuteReader() If reader.HasRows Then While reader.Read() Console.WriteLine(reader("Scroll")) 'output specific column End While End If Console.ReadLine() End Sub [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
Database
MS Access
search for sting in database
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom