Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old March 19th, 2004, 10:30 AM
nhunter nhunter is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 3 nhunter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question ADODC1 Search

OK I know this has been posted before but I am having serious troubles with it. I have written an application to search a Access 2000 database for a keyword (inputted by user). I would like my results to be displayed in a datgrid. Here is my code:


Private Sub cmdSearch_Click()

'Call_Logs is my database table name
'Call_Description is my field name in the above table
'txtSearch.Text is input on a form by the user

Dim mySql As String
Dim ConStr As String
Item = Trim(txtSearch.Text)

mySql = "select * from Call_Logs where Call_Description = " & Item

Adodc1.CommandType = adCmdText
Adodc1.RecordSource = mySql
'Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1.Recordset


what am I doing wrong? When I run this code I get no results. My datagrid still shows all entries in the table.

Thanks in advance for your help

Reply With Quote
  #2  
Old March 19th, 2004, 12:58 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 46 m 5 sec
Reputation Power: 180
Does the item you enter exist in the database?

I see you have adodc1.refresh commented out. You might try adodc1.requery in there somewhere, but I don't think you should have to.

Try the same sql in access itself & see if you get any records back.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old March 19th, 2004, 01:12 PM
nhunter nhunter is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 3 nhunter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes my item does exist in the database. I also have tryed adodc1.requery and also does not work. My code actually runs but I get the entire database showing up in my datagrid. Any other suggestions??


Quote:
Originally Posted by Doug G
Does the item you enter exist in the database?

I see you have adodc1.refresh commented out. You might try adodc1.requery in there somewhere, but I don't think you should have to.

Try the same sql in access itself & see if you get any records back.

Reply With Quote
  #4  
Old March 19th, 2004, 07:20 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 46 m 5 sec
Reputation Power: 180
Have you tried stepping through with the debugger? I'd be looking for what's in the item variable.

Oh, and if your call description column is a textual datatype you need to put ' around the where condition value

Reply With Quote
  #5  
Old March 22nd, 2004, 08:09 AM
nhunter nhunter is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 3 nhunter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I am still having problems with this. Here is what I have again:

Dim mySql As String
Dim ConStr As String
Item = Trim(txtSearch.Text)
mySql = "select * from Call_Logs where Call_Description = '" & Item & "'"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = mySql
Adodc1.Recordset.Requery
Set DataGrid1.DataSource = Adodc1.Recordset

My code runs but does not display in my datagrid. The datagrid shows the entire database instead of just
the records that my code should return.

Reply With Quote
  #6  
Old March 29th, 2004, 01:20 PM
hidwan hidwan is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 hidwan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
try this again it will work perfect

Dim mySql As String
Dim ConStr As String
Item = Trim(txtSearch.Text)
mySql = "select * from Call_Logs where Call_Description = '" & Item & "'"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = mySql
Adodc1.refresh '*************
Set DataGrid1.DataSource = Adodc1.Recordset

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > ADODC1 Search


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway