Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic (http://www.programmingforums.org/forum18.html)
-   -   Searching A Record (http://www.programmingforums.org/showthread.php?t=14694)

tau Dec 5th, 2007 7:42 AM

Searching A Record
 
Please Help I M Still New In Vb6 So I M Trying To Create A Databse So I M Looking For A Code To Search For A Certain Record In A Database How Do I Go About It

venkatramasamy Dec 6th, 2007 2:17 AM

Re: Searching A Record
 
HI Tau,

The details you furnished is not sufficient to guide you on right direction, the reason no information provided about the direction you want to go,

just tell me what database you are using like MS access, Oracle, SQLServer

Usually beginers use MS access...

if it so...

i assumed that there exists an Db named as MYDB.Mdb
:

create the database base connection
dim cn as new Adodb.Connection
dim rs as new adodb.recordset
dim strfound as boolean
cn.open (Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DBQ=C:\MYDB.mdb;DefaultDir=C:\;Driver={Driver do Microsoft Access (*.mdb)};DriverId=281;FIL=MS Access;FILEDSN=C:\MYDB.mdb.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;")

rs.open "select *from samp"
Strfound=false
if rs.reordcount>0 then
    rs.movefirst
      For i=0 to rs.recordcount-1
    if strcmp(rs.fields(fileldindex),searchvale,vbtextcompare)=true then
    strfound=true         
end if
      rs.movenext
Next     


end if

if strfound=true then
msgbox "Record Found"
else
msgbox "Record Not Found"


i hope the code will help

the code above furnishes was not cheked it simple guide line only you may need to make slight changes on it

all the best

With regards
venkatramasamy SN

Steel9561 Jul 21st, 2008 10:08 AM

Re: Searching A Record
 
You also can use a filter with VB6 and ADO which basically will let you perform better searches using the format "recordset.filter=". You can find more info about this on this site:

http://p2p.wrox.com/topic.asp?TOPIC_ID=6785


All times are GMT -5. The time now is 3:54 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC