need code to display a database in access using Datagrid

Thread Solved

Join Date: Dec 2008
Posts: 7
Reputation: rahmathmail is an unknown quantity at this point 
Solved Threads: 0
rahmathmail rahmathmail is offline Offline
Newbie Poster

need code to display a database in access using Datagrid

 
0
  #1
Dec 30th, 2008
hi,
i want to display one table in a access database using datagrid.
i tried to do like this.

con.open constring
set rs=con.execute("command to select the table")
set datagrid.DataSource=rs



but it shows an runtime error like this:
RunTime Error '7004'

The rowset in not bookmarkable



wats' the reason... pls post simlified answers.
coz i'm a beginer.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

Re: need code to display a database in access using Datagrid

 
0
  #2
Dec 30th, 2008
try to use this


rs.open "command to select the table"
set datagrid.datasource = rs

regards
Ryan Riel
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 7
Reputation: rahmathmail is an unknown quantity at this point 
Solved Threads: 0
rahmathmail rahmathmail is offline Offline
Newbie Poster

Re: need code to display a database in access using Datagrid

 
0
  #3
Dec 31st, 2008
hi ryan,

the error is still there.

just see the error discription i have posted.
any idea

regards,
rahmath.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

Re: need code to display a database in access using Datagrid

 
0
  #4
Dec 31st, 2008
is the con.open is your connection?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 7
Reputation: rahmathmail is an unknown quantity at this point 
Solved Threads: 0
rahmathmail rahmathmail is offline Offline
Newbie Poster

Re: need code to display a database in access using Datagrid

 
0
  #5
Dec 31st, 2008
yes bro!
here's the complete code.

dbConStr = Connection String
DataGrid = Name of MS DataGrid Control 6.0


con.open dbConStr
rs.open "select * from <tablename>", con, adOpenDynamic, adLockOptimistic
set DataGrid.DataSource=rs


here's the error no


RunTime Error '7004'
The rowset in not bookmarkable


please help me.
Last edited by rahmathmail; Dec 31st, 2008 at 2:23 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

Re: need code to display a database in access using Datagrid

 
0
  #6
Dec 31st, 2008
try this:

rs.open "select * from <tablename>", dbConStr, adOpenDynamic, adLockOptimistic
set DataGrid.DataSource=rs

regards
ryan riel
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 7
Reputation: rahmathmail is an unknown quantity at this point 
Solved Threads: 0
rahmathmail rahmathmail is offline Offline
Newbie Poster

Re: need code to display a database in access using Datagrid

 
0
  #7
Dec 31st, 2008
Tried that....

now the error is........

Runtime Error '91':
Object variable or with block variable not set

what i'll do....
pls..........
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

Re: need code to display a database in access using Datagrid

 
0
  #8
Dec 31st, 2008
you should set your rs if your using adodb u can use this

set rs = new adodb.recordset
rs.open "select * from <tablename>", dbConStr, adOpenDynamic, adLockOptimistic
set DataGrid.DataSource=rs

Regards
Ryan Riel
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 3
Reputation: Joel Salvo is an unknown quantity at this point 
Solved Threads: 1
Joel Salvo Joel Salvo is offline Offline
Newbie Poster

Re: need code to display a database in access using Datagrid

 
0
  #9
Dec 31st, 2008
'your code
dbConStr = Connection String
DataGrid = Name of MS DataGrid Control 6.0


con.open dbConStr
rs.open "select * from <tablename>", con, adOpenDynamic, adLockOptimistic
set DataGrid.DataSource=rs

'=======================
'modified version of your code
'=======================
'variable declaration

Private strSQL as string

dbConStr = Connection String
DataGrid = Name of MS DataGrid Control 6.0

strSQL = " select * from <tablename>"

'open database connection
con.open dbConStr

set rs = new Adodb.Recordset
rs.CursorLocation = AdUseClient
'only if you want to view records on datagrid
rs.open strSQL, con, AdOpenForwardonly, AdlockReadonly

'always check if there is a record
if rs.recordcount = 0 then exit sub
if rs.recordcount > 0 then
DataGrid.DataSource = rs
end if
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 7
Reputation: rahmathmail is an unknown quantity at this point 
Solved Threads: 0
rahmathmail rahmathmail is offline Offline
Newbie Poster

Re: need code to display a database in access using Datagrid

 
0
  #10
Jan 1st, 2009
sorry, the error is still there.
is there any property of datagrid that must be set while designing before executing?

regards,
rahmath.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC