473,383 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to bind a datagrid with the records of a recordsource through coding ??

How i can bind the datagrid with the record that are present in a recordsource through programming?

one more thing is that the no of record present in the recordsource may vary according the users input.
TIA

regards
vishwas
Sep 18 '07 #1
12 8593
debasisdas
8,127 Expert 4TB
if u are using ADO data control then
try this

Expand|Select|Wrap|Line Numbers
  1. Set DataGrid1.DataSource = Adodc1
Sep 18 '07 #2
no i am not using the adodc to connect.

i have the following connection string to connect to the database.

ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:\feemgmt.mdb;" & _
"Persist Security Info=False"
Set con = New ADODB.Connection
con.ConnectionString = ConnString
con.Open ConnString


so what can i do to to bind a datagrid with the records of a recordsource through coding.

plz help its urgent

TIA
with best regards
vishwas
Sep 18 '07 #3
no i am not using the adodc to connect.

i have the following connection string to connect to the database.

ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:\feemgmt.mdb;" & _
"Persist Security Info=False"
Set con = New ADODB.Connection
con.ConnectionString = ConnString
con.Open ConnString


so what can i do to to bind a datagrid with the records of a recordsource through coding.

plz help its urgent

TIA
with best regards
vishwas


is there anybody who can help me ????
Sep 18 '07 #4
i want to know about the working of a datagrid control

can anybody help me?

TIA

regards
vishwas
Sep 18 '07 #5
QVeen72
1,445 Expert 1GB
Hi,

Check This Code:

Expand|Select|Wrap|Line Numbers
  1. Dim RST As New ADODB.Recordset
  2. Set RST = Nothing
  3. RST.CursorLocation = adUseClient
  4. RST.Open "Select * From MyTable", Conn, adOpenStatic, adLockReadOnly
  5. Set DataGrid1.DataSource = RST
  6.  

Regards
Veena
Sep 18 '07 #6
Hi,

Check This Code:

Expand|Select|Wrap|Line Numbers
  1. Dim RST As New ADODB.Recordset
  2. Set RST = Nothing
  3. RST.CursorLocation = adUseClient
  4. RST.Open "Select * From MyTable", Conn, adOpenStatic, adLockReadOnly
  5. Set DataGrid1.DataSource = RST
  6.  

Regards
Veena
nothing is displayed in the datagrid by this code.
there comes the blank datagrid control
Sep 18 '07 #7
QVeen72
1,445 Expert 1GB
Hi,

It happens when, u have done any Binding at Design time/FormLoad to a datacontrol/Environment , then u have to remove that. Check This :

Expand|Select|Wrap|Line Numbers
  1.     Dim RST As New ADODB.Recordset
  2.     Set RST = Nothing
  3.     RST.CursorLocation = adUseClient
  4.     RST.Open "Select * From MyTable", Conn, adOpenStatic, adLockReadOnly
  5.     With DataGrid1
  6.         .DataMember = ""
  7.         Set .DataSource = RST
  8.         .Refresh
  9.     End With
  10.  

REgards
Veena
Sep 18 '07 #8
Hi,

It happens when, u have done any Binding at Design time/FormLoad to a datacontrol/Environment , then u have to remove that. Check This :

Expand|Select|Wrap|Line Numbers
  1.     Dim RST As New ADODB.Recordset
  2.     Set RST = Nothing
  3.     RST.CursorLocation = adUseClient
  4.     RST.Open "Select * From MyTable", Conn, adOpenStatic, adLockReadOnly
  5.     With DataGrid1
  6.         .DataMember = ""
  7.         Set .DataSource = RST
  8.         .Refresh
  9.     End With
  10.  

REgards
Veena
thanks a lot
but the result is the same,
datagrid comes empty
here is my code

Dim rs As New ADODB.Recordset
Set rs = Nothing
rs.CursorLocation = adUseClient
rs.Open "SELECT date,session from accounts where std_id= '" & txtSearchRoll.Text & "';", con, adOpenStatic, adLockReadOnly

frmShowSearchId.DataGrid1.DataMember = ""
Set frmShowSearchId.DataGrid1.DataSource = rs
frmShowSearchId.DataGrid1.Refresh

frmShowSearchId.Show


what can be the cause???

TIA
regards
vishwas
Sep 18 '07 #9
thanks a lot
but the result is the same,
datagrid comes empty
here is my code

Dim rs As New ADODB.Recordset
Set rs = Nothing
rs.CursorLocation = adUseClient
rs.Open "SELECT date,session from accounts where std_id= '" & txtSearchRoll.Text & "';", con, adOpenStatic, adLockReadOnly

frmShowSearchId.DataGrid1.DataMember = ""
Set frmShowSearchId.DataGrid1.DataSource = rs
frmShowSearchId.DataGrid1.Refresh

frmShowSearchId.Show


what can be the cause???

TIA
regards
vishwas

is there any body who can help me ?????
Sep 19 '07 #10
hariharanmca
1,977 1GB
No one is here to work your problem.
Try to solve your self then; post your query.
You have to try your best.
Sep 19 '07 #11
QVeen72
1,445 Expert 1GB
thanks a lot
but the result is the same,
datagrid comes empty
here is my code

Dim rs As New ADODB.Recordset
Set rs = Nothing
rs.CursorLocation = adUseClient
rs.Open "SELECT date,session from accounts where std_id= '" & txtSearchRoll.Text & "';", con, adOpenStatic, adLockReadOnly

frmShowSearchId.DataGrid1.DataMember = ""
Set frmShowSearchId.DataGrid1.DataSource = rs
frmShowSearchId.DataGrid1.Refresh

frmShowSearchId.Show


what can be the cause???

TIA
regards
vishwas
Hi ,

Write the above code of populating the DataGrid in Form_Load event of frmShowSearchID, not the calling form. thats bcoz, u may have declared the RST as local variable, and it may be out of scope for showing Form.

REgards
Veena
Sep 20 '07 #12
jrtox
89
is there any body who can help me ?????
Hi,

1. Try to Check your "RS"and "Con" if its declared as a global variable.
2. Check if your SQL statement is correct, use SQL builder if it is right.
3. Below is my way to retrive, Save, Update, data from my databse.


'Paste it everywhere as long as its trigger an action, eg in the command button, or during form_load.

sql = "SELECT * FROM Supplier WHERE Name='" & ComboBoxSupplier.Text & "'"
OpenDB (sql)
Set FormName.datagridName.datasource = RS


' Below are Coding in the my Module, Paste it there.

Function OpenDB(sql As String)

Connect

If RS.State = 1 Then
RS.Close
End If

RS.CursorLocation = adUseClient
RS.Open sql, CONN, adOpenDynamic, adLockOptimistic

End Function

'----------

'---------------
Function Connect()

Dim ESQL As String

Set CONN = New ADODB.Connection
If CONN.State = 1 Then
CONN.Close
End If

MSDatabase = App.Path & ("\DBase\datacaddtech.mdb")'Edit with your Database name and location.

ESQL = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MSDatabase & ";Persist Security Info=False"
CONN.Open (ESQL), , , 0


End Function


Regards.
Sep 27 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: FZ | last post by:
Hi Gang, I was wondering if a generous person might be able to walk me through what I believe is a pretty simple task. I actually have significant Access experience, but I haven't done it in...
7
by: amywolfie | last post by:
Is there a simple way to code: If (no related records) in VBA? I would be going from frmMain to frm2, where frm2 may or may not have a related record. I do have a PK_ID in frmMain and a...
5
by: Henry Su | last post by:
Hello All, I am looking to whip a recordset out of thin air through a series of database record manipulation (so there is no physical equivalence to any database entities such as a table or...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
2
by: Santosh | last post by:
Dear all i want to bind data to datagrid header template i am wrtting follwing code it is displaying data with in item template not but it is display data in header template <asp:DataGrid...
5
by: vai | last post by:
i'm working in visual basic. i want to dispaly the records in a datagrid control who's data source is adodc.i want to display the records for a particular date. i.e. if the date which i accept...
1
by: vishwaskothari | last post by:
hiiiii how can i bind a datagrid control to a recordsource through programming. TIA regards vishwas
1
by: adolph | last post by:
I wrote an access2000 database for a POS system. In it is a sales form with a a subform showing the items being purchased. The main form is unbound. It uses a class to hold the main form data...
17
lee123
by: lee123 | last post by:
I know this is a free site and the moderators or anybody don't have to answer if they don't want to.. but if there is someone who knows how to answer this question please help with this one. i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.