Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Populating A Datagrid In VB6

I'm having real trouble populating a datagrid from a recordset in vb6.

Here's my code.

Private Sub cmdSearch_Click()
Dim sConn As String 'for the connection string

Dim db As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sPath As String
Dim sSQL As String
Dim SubID As String

sPath = App.Path & "SSADM.mdb;"
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPath
db.ConnectionString = sConn
SubID = txtSubsID.Text
sSQL = " Select * From Subscriber WHERE SubscriberID =" & SubID & ""

With rs
.ActiveConnection = db
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open sSQL

lblName.Caption = .Fields("SubName").Value

End With

Set dgCurrentSubs.DataSource = Nothing
Set dgCurrentSubs.DataSource = rs
lblName.Visible = True

Set rs = Nothing
Set db = Nothing

End Sub
The connection obviously works as the label displays the field fine. Do I need to do anything to the datagrid itself? Currently, nothing loads into the grid. Even if I move the 'SET dgCurrentSubs' statements into the WITH it doesn't work.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Populating A Datagrid
i want to populate a datagrid and if some conditionals are not met i don't want to display the row. is there a way to load a datagrid manually?

not using:

DataGrid1.DataSource = therecordset

something more like:

dim r as long

do while not therecordset.EOF

with DataGrid1
dim x as integer
for x = 0 to 7 'seven columns in the query
.row = r
.col = x
.text = therecordset(x)

r = r + 1


this sort of grid filling seems to work with the flexgrids but not with the datagrid. i want to use a data grid so i can easily edit the data. i have been using a flexgrid with hidden text boxes to edit the data but with more than 2500 lines the grid takes forever to load.

anyone know how to write this for datagrid?

Populating A DataGrid
I am connecting to an Oracle DB and I need to be able to populate a DataGrid with the information I pulled from Oracle. Any ideas on how to do this? Thanks, Jeremy

Populating A Datagrid Without Using ADO
I was wondering if anyone knows how to populate a Datagrid without using an ADO connection to an SQL database. I would like to read the data into a Handle and populate the grid with that data, but I am LOST!!! Thanks in advance!

Datagrid Not Populating
Adodc1.RecordSource = "SELECT History.Transaction_Date, tblStyle.Style, History.Formula, History.Colour_Desc, tblStaff.S_F_Name FROM tblStyle INNER JOIN (tblStaff INNER JOIN (tblClient INNER JOIN History ON tblClient.C_Number = History.C_Number) ON tblStaff.S_Number = History.S_Number) ON tblStyle.Style_Number = History.Style_Number Where (((tblClient.C_L_Name) = ' " & txtLName.Text & " ' ))"

tried this code to populate a vb datagrid from an access table but only the correct headings come up but no details.

Can u help?

Populating The Datagrid
can you please tell me how to populate the data grid,datacombo using ADODB
also i want to know how to give the names of the week to the row name

my sql statement for population the datagrid is

select * from accomodation
and data combo is
select hotels from accomodation

DataGrid Not Populating

I have created a simple application to view a recordset in datagrid, the recordset is returned by one of the function of my dll.

The code works fine when accessing the DLL directly ie without registering it with COm plus but dosent work when its is deployed with COM + server . The component gets the recordset but setting it to the datagrid dosenot show any result

the code is as follows

Dim Objrs As ADODB.Recordset
Dim ObjTest As PrjTest.Clstest

Private Sub cmddetails_Click()
Set ObjTest = New PrjTest.Clstest

Set Objrs = New ADODB.Recordset
Set Objrs = ObjTest.Reterive

Set DG1.DataSource = Objrs
MsgBox "over"

Set ObjTest = Nothing

End Sub

This code works well when not deployed in com plus server . please let me know if any seeting has to be ennabled for the same to work

thanks for the support

Populating A Datagrid
I have a form and placed a datagrid on it. I need to programmatically create the connection to the SQL database and then table.

Because I need to be able to update the information in the table, I'm not sure if I need to use a reader or an adapter.

Can someone please provide some sample code so that I can understand how to do this ?


Populating DataGrid In VB 6.0

I'm trying to display the information from a table into the datagrid.

I have a connection to the database and getting a resultset is fine, but now I want to link it to the datagrid.

Set Conn = New ADODB.Connection
Conn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
          "Dbq=" & DataBaseName & ";" & _
          "Exclusive=1;" & _
          "Uid=admin;" & _

which is the database connection, now I get the recordset

Set RS = New ADODB.Recordset
strSQL = "select * from test_db;"
RS.Open strSQL, Conn

Now RS contains the information from the Query and I want to get this displayed on the screen using a dataGrid. How do I put the information of the Recordset into the dataGrid.

I tried using something of this fashion but I kept getting errors.
DataGrid1.DataSource = RS

thanks for your help in advance,


Populating A Datagrid
Hi im trying to populate a datagrid.

I've already connected to the database (Access) and wrote a SQL query and set a recordset that will take the values. But how do I populate the datagrid with the query results?


Populating A DataGrid
I have a form with a DataGrid that I need to populate with rows from an Oracle Database. I have the connection to the DB and the SELECT string, now I need to know how to get rows from a Recordset/DynaSet to the DataGrid. Any ideas? Thanks in advance, Jeremy

Edited by - JCScoobyRS on 10/11/2002 8:55:20 AM

Populating A DataGrid
I was wondering if it is possible to populate a datagrid from text boxes or a string array? If so could someone provide me with an example of this.

Thank you.

Populating A DataGrid
I am having a strange problem with Datagrid control...

My Datagrid has 7 columns and it is populating at run-time with an ADO recordset, but when I execute the Refresh method of the control, it changes the columns' names to the names of the fields in the database.

Here is at happens:
At start, my DataGrid has the following columns (it's portuguese):
Emitente | Banco | Agencia | Documento | Valor | Deposito | Dias

After, I execute the following code:

rsCheques.Open "select [NOME], [CODIGO BANCO], [AGENCIA], [DOCUMENTO], [VALOR FACE], [DATA DEPOSITO], [DIAS TOTAL], [CODIGO CHEQUE] from [CHEQUES] where [NUMERO LOTE] = " & xLote & " order by [CODIGO CHEQUE] desc", cnBanco, adOpenDynamic, adLockOptimistic
set dgLote.DataSource = rsCheques 'dgLote is the datagrid

And now, the columns' names is changed to the fields that I used in the Sql statement of the method Open of the rsCheques recordset.

I hope you can understand me, my english is not so good...

Thank you

Populating A DataGrid Part 2
Now I need to be able use a textbox and type into it and the datagrid automatically go to the first record where the letter(s) appear. Do you know how to do that? Thanks, Jeremy

Populating A DataGrid From 3 Sources
Hi Again,
I have a problem which Im sure some one here will be able to help me with or telll me where to look.

My problem is that I have a Datagrid showing all absences an agent has taken. Now Im trying to get another datagrid which will link to the other datagrid counting how many (Vacation Days, Wellness Days etc) that have been used and will display on another column how many days they have left.
So altogether there will be 3 columns Type (Type of Absence), Used and Available.

I already had this had the Type of Absence and Availble Displayed as Labels, but my Boss wants it displayed in a Datagrid.
Can someone help me to get the info I already have in to a DataGrid

Thanks in Advance.

Populating A DataGrid From A Recordset
I'm trying to populate a DataGrid from a Recordset. I've been trying for hours but it won't work. Any suggestions.

my recordset is generated like this:

Private Sub Form_Load()

Dim conStr As String
Dim rstResult As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim strSQL As String
Dim i As Integer

strSQL = "SELECT nachname, vorname FROM tabconsultant"

conStr = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;database=cuvimas;UID=sa;PSW=;"
Set cnn = New ADODB.Connection
Set rstResult = New ADODB.Recordset
cnn.Open conStr
rstResult.Open strSQL, cnn, adOpenStatic

'this is my attempt sofar

Do Until rstResult.EOF = True
For i = 0 To 1
Debug.Print rstResult(i)
dgNames.Columns(0).Text = "nachname"
dgNames.Columns(1).Text = "vorname"

Next i




Thank you in advance.


DataGrid/MSHFlexGrid Not Populating
This bit of code is called when a duplicate record is found:

Private Sub DuplicateFound(ByVal x As String)
Form1.Show vbModal
Dim adoRsDuplicate As ADODB.Recordset
Set adoRsDuplicate = New ADODB.Recordset
With adoRsDuplicate
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.ActiveConnection = adoCn
.Open "SELECT * FROM Clients WHERE FirstName = '" & x & "'"
End With
Set Form1.DataGrid1.DataSource = adoRsDuplicate
Set Form1.MSHFlexGrid1.DataSource = adoRsDuplicate
Set Form1.MSHFlexGrid1.Recordset = adoRsDuplicate
End Sub
It opens a new form which displays the duplicate data. I've been reading through threads on here and by all accounts this should work - but neither grid is populated. Any ideas?

Incidentally, I won't actually have two grids on the form - neither will the form be called Form1. I am just using it for testing purposes.



Newbie - Populating Datagrid With SQL
Hi there,

On my web site I have a stored procedure that downloads all mail on the users server to a database. Now I am creating a program that allows the user to edit their web site from their computers. And also read the table which this stored procedure fills.

Can anyone help me just get the Datagrid controls 6.0 working so It will connect to my recordset ( database ) and populate the datagrid.

Heres my recordset:

Private Sub Form_Load()

Set MydsEncrypt = New dsEncrypt
MydsEncrypt.KeyString = ("********")

Dim DataTable As String
Dim Username As String
Dim Password As String
Dim ID As String
Dim Address As String

DataTable = MydsEncrypt.Encrypt(ReadIniValue(App.Path & "userdata.ini", "SQLLogin", "DataTable"))
Username = MydsEncrypt.Encrypt(ReadIniValue(App.Path & "userdata.ini", "SQLLogin", "Username"))
Password = MydsEncrypt.Encrypt(ReadIniValue(App.Path & "userdata.ini", "SQLLogin", "Password"))
ID = MydsEncrypt.Encrypt(ReadIniValue(App.Path & "userdata.ini", "SQLLogin", "ID"))
Address = MydsEncrypt.Encrypt(ReadIniValue(App.Path & "userdata.ini", "SQLLogin", "Address"))

Dim Connection As ADODB.Connection
Set Connection = New ADODB.Connection "Driver={SQL Server};Server=" & Address & ";Database=" & DataTable & ";Uid=" & Username & ";Pwd=" & Password & ";"

Dim User_Details As ADODB.Recordset
Set User_Details = New ADODB.Recordset "SELECT * FROM Users WHERE ID LIKE '" & ID & "'", Connection, adOpenDynamic, adLockOptimistic, adCmdText

End Sub
The name of the datagrid so far is "dg_inbox"

If anyone can help! I would totally appreciate it!

Thank you in advance.


Populating A FlexGrid/Datagrid Either
Lads I have a Database called OSD.mdb

Option Explicit
Dim conProject As ADODB.Connection
Dim rsProject As ADODB.Recordset

Private Sub Form_Load()

Set conProject = New ADODB.Connection
Set rsProject = New ADODB.Recordset

conProject.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Persist Security Info =False;Data Source =" & App.Path & _
"OSD.mdb;Mode = readwrite"

I have a text box named txtStartDate
And a text box named txtEndDate

I want to populate a Datagrid based on these results.
I.e with the results of projects with a start date or in end date within that time frame.

can someone please explain how to do this with code for:
a FlexGrid - MSFlexGrid1
a Datagrid - DataGrid1

I appreciate it thanks

Populating A DataGrid Through A Class
I am trying to populate a datagrid without using an additional control such as ADODC. I have spent hours trying to create a data source class that I could use to substitute for the control, but have had no luck. I want to be able to change the datagrids contents during run time by changing the source for the class. Does anybody have any ideas on what I could do, or an example of a data source class that I could see?


Populating Datagrid From Array

I'd like to populate a datagrid from an array which my VB program already has in memory. I'm currently using MsFlexGrid, but I'm entirely happy the functionality in provides. Has anybody populated datagrid from an array before?

Thanks for the help,

Problems In Populating A DataGrid
Hi all !

I'm having problems filling a dataGrid without the use of an Adodc control.
What I want to do is to add records to a dataGrid from a dataBase and finally to add an empty column for my use (this column I need to be unbounded to the dataBase).

Please, experts...wherever you are...People are desperate !

Thanks in advance !


Populating DataGrid With Results From VAX
All my data is on a vax and I use RDB/VMS. Some of the dates are in an ansi format. If I create a recordset that selects any ansi dates the datagrid will not populate. If I remove the dates from the select statement it works fine. Any suggestions?

DataGrid Not Populating For 1 Of 20 Users
I have the .exe for my VB6 application on a Network drive.
There are multilple users that access this .exe thru a shortcut
on their PCs. Within this application I have a DataGrid that
lists any associated Materials to the Specific Material the User
is modifying. If the user edits the list, the DataGrid refreshes
and displays the information.

My question is, I have one user out of 20 that the DataGrid
will not populate. Other users accessing the exact same application, the DataGrid works fine. What should I be looking for on this one user's Computer? A missing .dll file ? If so any idea which one?

Appreciate any ideas.

Values Are Not Populating In The Datagrid
values are not populating in the datagrid ...?

Populating A Record On DataGrid From A Form
Hi all,

I was wondering if anybody can help me with this issue.

I have two forms, form 1a has a datagrid where I want to populate details from another form. Form 1b has fields where a user will enter data.

Form 1b will have a command button to add a record to the data grid on form 1a.

Can anybody help me with this.

I did this before but using a record set. I do not know how to do it from a form.

Help please!!!!!!!!!!!

Thanks in advance.


DataGrid Not Populating In Private Function
I could populate the datagrid in the form load function. However when i move it to its own private function, it wont populate. Doesn't give me any errors, not sure what I'm missing. Heres the Code.

Private Sub Form_Load()

Populate_DataGrid (txtIdNum.Text)

End Sub

Private Sub Populate_DataGrid(IdNumber As String)
Dim dbCon2 As ADODB.Connection
Set dbCon2 = New ADODB.Connection
dbCon2.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;" _
& "Persist Security Info=False;Initial Catalog=AdeptTest;Data Source=KEVIN"

Dim rs2 As New ADODB.Recordset
Dim sql2 As String
sql2 = "Select * From PatientPA Where PatientID =" & IdNumber & ""
rs2.Open sql2, dbCon2, adOpenKeyset, adLockOptimistic
Set dgPANumbers.DataSource = rs2
Set rs2 = Nothing

End Sub

Populating A Datagrid From A Database Table
Hi All,

I currently have a working program which populates data into a ListBox using .AddItem but i want to change it to a DataGrid and I'm not sure how to populate the fields.

I have Module file which has the following procedures to handle Database Connections

Public Sub Connection()
CConnect.ConnectionString = "TimesheetData"
End Sub

Public Sub JobsRecordset()
JobsRecSet.ActiveConnection = "DSN=TimesheetData"
JobsRecSet.Source = "Select * FROM Jobs ORDER BY JobCode ASC"
JobsRecSet.Open "Jobs", CConnect, adOpenDynamic, adLockOptimistic
End Sub

Public Sub CloseJobsRecSet()
Set JobsRecSet = Nothing
End Sub

Public Sub CloseConnection()
Set CConnect = Nothing
End Sub
I have a form which allows users to Add/Edit Jobs. I have added a Datagrid named dgdJobs and it has 2 columns named "Job Code" and "Job Description". Since I'm using an ODBC connection the Datasource and DataFields for the 2 columns are empty.

I have a procedure that is called with the Jobs Form Activates as follows:

Private Sub LoadDataGrid()



End Sub
The part that is missing is how to add the information from the Recordset to the Datagrid.



List Of Values Populating In A Datagrid VB-6.
I have a Datagrid (ADO) linked to Oracle database. My question is as follows.

The First Cell of Datagrid should be linked to the Product Master and on clicking it should display (Populate) the list of values (ie, the products) from the product master.
The 2nd cell should be linked to a tax master and should populate with tax rates.

How to achive this conditions.




Populating A Datagrid With The Results Of A SQL Statement
Dim strCompany As String
    strCompany = txtCompany.Text
    Dim findSQL As String
    findSQL = "Select * " & _
              " from Client " & _
              " Where name like '" & strCompany & " '%"

the above is a SQL statement and i wish to populate a datagrid (either on the same page or a different one) with the results of the statement. How do i do this? Thank you!

Populating A Datagrid Relating To A Specific Value
my datagrid is bound to a table called OrderDetails. this table contains the following fields:
OrderNo (PK), ProductCode(also PK), ProductDesc, Quantity, Price.
the datagrid displays all the fields in the table, except order number. Records are added incrementally to the table (hence, also the datagrid) when a button is pressed. however, i want it to display only records relating to a specific OrderNo (ie the value in the textbox txtOrderNo.Text). how would i go about this? i have tried tying it to a SQL statement but i am very unsure of the syntax, as you can see from the following snippet:
Dim tSQL
tSQL = "Select ProductCode, ProductDesc, Quantity, Price From OrderDetail Where OrderNo = " & iOrderNo & ""
Set RS = Conn.Execute(tSQL)
Set DataGrid2.DataSource = RS

MsgBox ("Adding record to the datagrid")
Thanks in advance!

Populating DataComboBox's And Fill DataGrid
On my form, I'm trying to populate a second DataComboBox from the selection of the first DataComboBox.

Then select from the second DataComboBox and have the third DataComboBox populated.

Finally once I select from the third DataComboBox a DataGrid will be filled in with the results.

I found Deke's reply to post (#4691) to be helpful. I'm a little confused now, could someone point me in a direction.

I have been using BIBI.mdb as a example.

Thanks in advance,
Mike "the Rat"

Populating Datagrid With Input From Combobox
I have a MS database. In this db one of the columns is "Category". I want the user to select a Category from a combobox and have the datagrid display all info within the db with that Category name.

Populating Datareport With Contents From A DataGrid
I know that DataReports are usually bound to recordsets, but i was wondering if there's any way to bind one to the current contents of a DataGrid. The reason i ask is because the contents of the datagrid is already exactly what i want to be put into the Report. Any help/direction would be greatly appreciated

Populating Datagrid Based On Same Field In Database
I have a complicated question, so if i dont explain it properly, or dont supply enough information, please let me know! I have 3 datacombos - 1 for product type and 2 for price Descriptions. for each combo, i wish to populate a column in the datagrid. for the first column, products are populated based on the product type chosen and prices are populated (relating to the products) based on the price descriptions chosen. This would be fine if it was only the product type and 1 of the price combos that i was using but the fact that i am using 2 price descriptions. ( i am using the same fields for comparison purposes). is there anyway i can get around this - my SQL statement isnt working( due to the fact that teh same field is being used twice). do i need to use 2 Adodcs? is it possible to populate a column of the datagrid from a SQL statement? you will see the relationship between the tables here:
Product Type: TypeCode, TypeDescription
Product: ProductCode, ProductDescription, TypeCode
Price: PriceCode, ProductCode, Price
PriceDescription: PriceCode, PriceDesc

Any help would be greatly appreciated!

Object Variable- Datagrid Populating Error
I am gettin Error 91 - Object Variable or width block not set when I try to populate my datagrid with a recordset...any ideas?

I think the problem may be b/c i do not have a object library selected in my references? Any ideas as to which reference i have to select??

mySql = "SELECT * FROM MasterList"

rs.Open mySql, CurrentDB, adOpenStatic, adLockBatchOptimistic

Set grdVisit.DataSource = rs


Below is my database connection code:

CurrentDB.Open "Patient", "Provider=MSDASQL.1;Persist Security Info=False; Data Source=Patient"


Populating A DataGrid Based On A Combo Box Selection
Hi everyone,

I have a VB6 form that displays results in a DataGrid based on a combo box selection with user names. The combo box is populated with data from SQL Server stored procedure, shown below. However I need to filter the results based on combo box user selected and on the Option button criterias whether the job has finished (i.e All finished jobs)or still alive.

I was told that I can filter that from within the vb code with a recordset filter but I don't know how. See VB code below where I am atempting to do it.

Can anyone please help?

Thank you


SELECT R.RequestID, R.ShortDescription, RTRIM(U.FirstName) + ' ' +RTRIM(ISNULL(U.LastName, '')) AS 'User Name',
D.Department, R.StartDate, R.EstimateDate, R.FinishDate, R.LastUpdate

Department D ON U.DepartmentID = D.DepartmentID

VB Code:
Private Sub cmdSearch_Click()    Dim cmd As ADODB.Command    Dim rst As ADODB.Recordset    Dim Temp$        Set cmd = New ADODB.Command    Set rst = New ADODB.Recordset        'OpenConn        If Me.cboSearchFor.Text <> "" Then                'option button Finished clicked        If Me.optSearchFor(0).Value = True Then                        Temp$ = Me.cboSearchFor.Text                     rst.Filter = Temp$           rst.Filter = adFilterNone           Call GetSearch                   End If    End If           If Me.cboSearchFor.Text <> "" Then        'option button Live clicked        If Me.optSearchFor(1).Value = True Then                        Temp$ = Me.cboSearchFor.Text                     rst.Filter = Temp$           rst.Filter = adFilterNone           Call GetSearch                       End If       End IfEND Sub

VB Code:
Private Function GetSearch(Optional UserId As Integer)     Dim cmd As ADODB.Command    Dim rst As ADODB.Recordset     Set cmd = New ADODB.Command    Set rst = New ADODB.Recordset        OpenConn        With cmd        .ActiveConnection = cn        .CommandType = adCmdStoredProc        .CommandText = "SP_CREQUEST_SEARCH"                        Set rst.DataSource = .Execute                Set Me.grdSearch.DataSource = rst            End With        CloseConn End Function

Populating A DataGrid Based On A Combo Box Selection
Hi everyone,

I am designing a VB6 form which displays results in a DataGrid based on a combo box selection with user names. The combo box is populated with data from a SQL Server table. However I am finding difficult to populate the DataGrid, I get only empty Grid headers with no data even though data exists for a user name selected in combo box.

The VB code and the stored procedure code (which makes to populate the Grid) are shown below.

Can anyone please help?

Thank you

VB Code:
Private Sub cmdSearch_Click() Call GetSearchResults    End Sub

VB Code:
Private Function GetSearchResults(Optional UserId As Integer)     Dim cmd As ADODB.Command    Dim rst As ADODB.Recordset     Set cmd = New ADODB.Command    Set rst = New ADODB.Recordset        OpenConn        With cmd        .ActiveConnection = cn        .CommandType = adCmdStoredProc        .CommandText = "SP_CREQUEST_SEARCH"                '.Parameters.Append .CreateParameter("RequestID", adInteger, adParamInput, , RequestId)        .Parameters.Append .CreateParameter("USerID", adInteger, adParamInput, , UserId)                Set rst.DataSource = .Execute                Set Me.grdSearch.DataSource = rst            End With        CloseConn End Function


SELECT R.RequestID, R.ShortDescription, RTRIM(U.FirstName) + ' ' +RTRIM(ISNULL(U.LastName, '')) AS 'User Name',
D.Department, R.StartDate, R.EstimateDate, R.FinishDate, R.LastUpdate

Department D ON U.DepartmentID = D.DepartmentID

WHERE U.UserId = @UserId

I also need to populate the DataGrid based on Department combo box selection and other Option button criterias whether the job has finished (i.e All finished jobs)or still alive (i.e. All ongoing jobs). Any suggestion to how I go about it?

Please be kind, this new for me.

Values Are Not Populating From Datagrid 6.0 To Excel Sheet
values are not populating from datagrid 6.0 to Excel sheet ...?

Populating Data From Datagrid 6.0 To Excell Sheet
populating data from datagrid 6.0 to excell sheet ...?

At Runtime Connecting Populating A Datagrid With A Recordset. How?
Anyone know how to populate a ado Datagrid from a recordset at runtime? I've tried using the below code but it doesn't work.

 strSQlGrd = "Select fsono as Sale_Order,fcinvoice as Invoice_Number, " _
           & "fnamount as Amount, finvdate as Invoice_Date " _
           & "From armast " _
           & "Where fsono = '" & Trim(Me.txtSO) & "' And finvtype = 'P'"
    MsgBox strSQlGrd
    rsGrid.Open strSQlGrd, cn1, adOpenStatic, adLockReadOnly
    PMGrid.DataSource = "rsGrid"

I've also tried using the data envirnment with a command object, it works but had problems with that. See above post:{.

Edited by - rickyc1 on 2/8/2002 6:42:41 AM

Populating Datagrid Based On Runtime Parameters.
I need help in importing data from SQL server tables to Datagrid based on the parameters passed to the stored procedure during runtime.
What i mean is i've a stored proc. prcEmp, a recordset rs and a datagrid dg on the form. Now i want to pass 2 parameters to prcEmp from the form based on which the datagrid should be populated. The datagrid should be refreshed as n when the parameters change. How can i pass parameters from the form to the recordset n to the stored procedure?
Can u pls help me with this?
Thank you.

Populating DataGrid W/ Combo Boxes, Like Access Columns
In Access, you can have columns with combo box for the cell. Meaning you would click on a cell and a combo box would appear.

Right now I have information populating a DataGrid in VB but I want to have combo box in a similar fashion to whats in Access. I normally do a search for my question and of course there are hundreds of posts about combo boxes. However, I didn't see a post, or rather a SOLUTION as to how I would do this or if it can be done.

To reiterate, I have a DataGrid which is getting all its information from a table in Access and now I want to click on a cell in the DataGrid and have a combo box appear. Can this be done? If so, how?

Thank you,

Problem In Populating Data From Datagrid To Excel Sheet
problem in populating data from datagrid to Excel sheet ...?

Populating DataGrid W/ Combo Boxes, Like Access Columns
In Access, you can have columns with combo box for the cell. Meaning you would click on a cell and a combo box would appear.

Right now I have information populating a DataGrid in VB but I want to have combo box in a similar fashion to whats in Access. I normally do a search for my question and of course there are hundreds of posts about combo boxes. However, I didn't see a post, or rather a SOLUTION as to how I would do this or if it can be done.

To reiterate, I have a DataGrid which is getting all its information from a table in Access and now I want to click on a cell in the DataGrid and have a combo box appear. Can this be done? If so, how?

Thank you,

Populating Textboxes When Datagrid Row Change Or Current Cellchange.
I am using Vs .NET
I am trying to populate textboxes when I move to different row in my datagrid to reflect the record in the grid.
please help me with the code under grid_CurrentCellChanged procedure to populate the textboxes so that the textboxes reflect the record in the grid.

Tutorial On Populating A DataGrid With Data From A Microsoft Access Database
can someone plz tell me how to do this or give me a link to a tutorial

i have been searching the net and this forum for ages and aint been able to find a simple tutorial that explains how to simply add data from an access database to a datagrid on my VB 6 form

Populating A Datagrid Based Around A Parameter Query In A DataEnvironment Command

I'm trying to populate a data grid using a command from a dataenvironment. The command needs a parameter passing to it to generate the relevant results, how do I do this? Is it in the properties? Or do I need to somehow assign the command to the datagrid in the code?

I have tried various ways but can't get the grid to populate, I think its because it doesn't know what the parameter is but I can't find where to pass it. Also all the tutorials and examples i've found are based around using ADO controls which i'm not using in my project.

I'd appreciate any help! Thank-you

Datagrid Help Please How To Auto-requery The Recordset To Update The Datagrid??
I would really appreciate some help. I am trying to get the datagrid to update after inserting some records from another table into it. If I wait a few seconds after the insert, I can do rs2.requery and that works but I would like to grid to refresh on its own if possible. I'm sure there is a way. Below is the sub from the form. The OnLoad just opens the tables, etc. And the other one does the sql statement for inserting. If I wait a few after the insert, I can requery on rs2 and it works. Any suggestions?


Private cn2 As ADODB.Connection
Private WithEvents rs2 As ADODB.Recordset

Dim DbFile As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim SQLstmt As String

Private Sub AddCmd_Click()
SQLstmt = "INSERT INTO PR2 SELECT classification, organization, state, email FROM PR1 WHERE Classification = '" & DataList1.Text & "'"
'Get the Records
Set rs = New ADODB.Recordset
rs.Open SQLstmt, cn, adOpenStatic, adLockOptimistic, adCmdText
Label3.Caption = "Selected Business Contacts (" & Trim(Str(rs2.RecordCount)) & ")"
End Sub

Private Sub Form_Load()

Set cn2 = New ADODB.Connection
cn2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database1.mdb;Persist Security Info=False"
cn2.CursorLocation = adUseClient

Set rs2 = New ADODB.Recordset
rs2.Open "pr2", cn2, adOpenDynamic, adLockPessimistic, adAsyncFetch
Set DataGrid1.DataSource = rs2

DbFile = App.Path & "database1.mdb"
Set cn = New ADODB.Connection
cn.CursorLocation = adUseClient
cn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DbFile & ";" & _
"Persist Security Info=False"

End Sub

Adding Columns To A Datagrid And Binding The Datagrid To A Recordsource
I am working on a program in visual basic 6 that I inherited. I am trying to add a datagrid to a form, add colums to the datagrid(it gives you 2 columns at design time)and bind the datagrid to a recordsource.

I would appreciate any help.

Copyright 2005-08, All rights reserved