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




Clear Data From Datagrid Control?


I am use to using the MSHFlexGrid and now since the datagrid is a .NET control and the FlexGrid is a COM control I am using the datagrid now. This is a really basic question. I have a datagrid I add data to from an Excel Doc using OleDb. Once it is filled with the file my program allows you to export the data. What I need is this how do I clear the datagrid when I import data from another Excel doc? There is no DataGrid1.Clear method.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Clear Data From Datagrid Control?
can anyone help me with this...please..

how do I clear contents of datagrid control? thanks in advance...

Datagrid & ADO Data Control
Newbie question. I have created a Datagrid control bound to an ADO Data Control using a particular database account and password at design time. How do I use a different account and password at run time? The datagrid control apparently wants to connect first using the design time account/password before I can change the connection using code. In other languages, data sources can be disconnected at design time. I don't see how this is done with an ADO control.

Any help greatly appreciated.

Datagrid: No Ado Data Control
I am trying to populate a datagrid control without having to bind it to an ado data control.

the data, however, is not being displayed. The recordset is retrieving the records from my database but nothing is being displayed in my datagrid.


Here is my code
dim rsS as adodb.recordset
set rsS=new adodb.recordset

rsS.CursorLocation = adUseClient
rsS.CursorType = adOpenStatic
rsS.LockType = adLockOptimistic
rsS.Open "Select School_ID,School_Name,Address,Telephone from School Order by School_Name", connection

Set dgSchools.DataSource = rsS


Do I have to loop through the recordset and set the datafield property of the datagrid columns to the fields in the recordset?

I thought that by setting the datasource property that would be automatically done.

Tesita

Datagrid & ADo Data Control
I have a lookup window that uses datagrid and ADO data control as the data source. After compiling my application that uses this lookup, and deploy it to the target machine, the lookup window on popup does not display data.

However, when i installed VB6 Disk 1 on the target machine and run my application, the lookup window works.

pls how can i figure out the missing file in my application?

thanks

Datagrid,recordset % Ado Data Control
hi, i have a problem with datagrids.

i want to view the result of a query into a datagrid.
i created a recordset(rs) containing the data.
so, i added an ado data control(adodc1) , configured the connection and i wrote:

adodc1. recordsource =rs

after i wrote

set datagrid1.datasource=adodc1

but in the datagrid only the FIRST row of the recordset is shown?
why?

thanks

How To Display Data In DataGrid Control
please tell me how to display data in DataGrid control, the simplest way to do it. please this is very urgent to me

Inserting Data Using DataGrid Control
On a form, I have a combo box and a data grid.

Based on user's select in the combo box, data grid displays certain data which is supplied by stored procedure.

ComboBox On_LostFocus()
dataGrid.dataSource = rsStoredProc
end ComboBoxSub

Thats how my dataGrid gets it data. I have set the AllowUpdates, AllowInsert, AllowDelete properties of the dataGrid to TRUE. But still there is no additional row on the dataGrid for the user to add data, neither can the user edit or delete.

What is wrong here. Please suggest.

thank you in advance!
Ankeet

DataGrid And ADO Data Control PROBLEMS!
Hi,

I am quite new to database programming in VB.

I have a database that keeps track of different types of accommodations.....and also all the different units that eacy accommodation has.

For example........one accommodation is "Hotel"
and units could be 1, 2, 3, etc

What i want to do is make the program automatically display all the units in a data grid control for the selected type of accommodation.

I've tried doing this...

Adodc2.RecordSource = "SELECT tblUnits.UnitNumber FROM tblUnits WHERE tblUnits.AccTypeID = " & txtAccTypeID.Text

in order to change the data, but this doesnt do anything...the same units are displayd no matter which accommodation type is chosen.

What is the best way to do this?.......any help or advice you can give me would be welcome.

Thanx,
Clint

Data Control & DataGrid Ocx Problem
Hi,
I’m using a VB6 Pro SP4 (the latest). Here’s the problem:
1. I add Data control and DataGrid control (MSDATGRD.OCX) to the form
2. I connect Data control to Biblio.MDB and set RecordSource to one of the tables (Authors)
3. When I try to set DataSource of DataGrid I get the following error

Error Message:
No compatible data source was found for this control. Please add an OLEDB data source such as Data Enviroment or Microsoft ADO Data Control to the form or project.

I also get this message:

Error Message:
Can't bind this control to Data1. Select a different data source (eq - ADODC1, or DataEnviroment1...)

I would really appreciate your help for I need to use data control & bound it to data grid ocx.

Thanks.

Adding Data In DataGrid Control
Hello Friends,
     i am using DataGrid Control and bounded it with database of SQL Server amd adding or updating data from Grid. But the problem is some times it will allow to add or update and sometimes it is not allowing me. I am also selected AddAllowNew property become true.
   so what can i do plz reply me


SPPatel



Edited by - sppatel237 on 3/10/2004 7:52:00 PM

Changing Data In A Datagrid Control
I'm trying to modify data in a DataGrid control through code. I'm able to read what's currently there, but i can't seem to find the property/method that will let me change the data in a certain cell. I'm guessing it MUST be possible, since the user can do it during runtime. Any help would be greatly appreciated.


Thanks

Modifying Data In Datagrid Control ?
hi,
I set up my datagrid control based on a command object in a data environment.
Everything displays nicely, except that I can't edit, add or delete anything.
Does anybody know why ?

thanks,
Maggie

How To Clear The DataGrid...?
Dear Friends,

I have a project for Sales, and every time I have to clear the DataGrid when I Post the Transaction sales or Cancel it.

I'm trying to do this code to delete the table but doesn't work till now coz I have to make refresh to the record set and I don't know how?
anyway this is the code


PHP Code:




If rs.RecordCount > 0 Then
     rs.MoveFirst
         For aloop = 0 To rs.RecordCount - 1
      Cn.Execute ("delete * from TmpDetails")
      rs.MoveFirst
                 DataGrid1.Refresh








So I hope if there is anyone can help me and if there is any Questions plz let me know

note that I'm not using any Data Control (ADO) to connect I programmed it by code only

and thx alot

Best Regards

How To Clear Datagrid???
I had read abount the clear method in the MSDN and i duno how to code it. Sorrie I know it is easy to you all.

How To Clear Datagrid
dear All,
how to clear datagrid ? is there anything like datagrid.clear command ?
Pls advise ....TIA

Jas

Clear Datagrid
Hi All,

How to clear all rows i datagrid.

To fill I used : Set Datagrid2.Datasource = MyRst

Is there anything like Datagrid2.ClearAll or maybe
just closing MyRst.

Datagrid2 is a result but when I start a second event
it keeps the old result on the form until the event stops.
Then it will fill datagrid2 with the correct result.



cheers
Ray

***HELP*** How Do I Clear Datagrid ??
Hi,

As a newbie to VB, I need help with clearing a datagrid. Here' s the code:

    With Adodc1
            .RecordSource = "select * from Project"
            .Refresh
    End With
    
    Set dgdProjects.DataSource = Adodc1

How do I clear the results displayed in the grid after executing the above code? I've searched the forum and the web but have not been able to find an answer.

Any help would be much appreciated.

Many Thanks, Ash

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                                    **** KNOWLEDGE IS LIMITLESS ! ****
    **** FOR EVERY KNOWLEDGEABLE, THERE EXISTS A MORE KNOWLEDGEABLE ! ****

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Edited by - mchu6am4 on 9/15/2004 2:45:05 PM

Problem Using An ADO Data Control And An ADO Datagrid In Excel.
Hi,

I'm trying to use an ADO Data Control and link a ADO DataGrid to it to be able to browse/update an Access DB Table. Normal in VB6.0 you setup the ADODC and then just assign the Datasource property of the DataGrid to be the ADODC and it works. In Excel there is no Datasource property in the properties window and when I try to do it through code int the Form Initialise event I get the following error 'Method or Data Member not Found'.

Does anybody have any ideas what I'm doing wrong or how you link a DataGrid to an ADODC in Excel?


Thanks,
Phil.

Datagrid Control Does Not Refresh With Data Environment
Dear Friends,

I am facing a problem with DATAGRID IN VISUAL BASIC 6.00.

I am using a DATAENVIRONMENT with a Connection Object that has OneCommand Object.
The command Object uses the Following Parametric SQL Statement.

SELECT * FROM mondet WHERE cntno=?

Pls note that Mondet is a child table with multiple entries in CNTNOfield - (ACCESS Table)

The Datagrid has the following Data Properties (Thru the PropertiesPage)
The Name of The Data Environment is DE1
the Name of the Command Object is COMMAND1

DATAGRID1.DATASOURCE=DE1
DATAGRID1.DATAMEMBER=COMMAND1



The Datagrid refreshes the first time. But when we run the parametricSQL Statement again to create a new


Recordset, a new Recordset is Created (Checked the Recordcount Propertyof RECORDSET in MSGBOX)


but the DATAGRID is not updated. I have Tried "Rebind", "Refresh"Methods etc. but to no avail.


Infact even the "Clearfields" method does not Work after the FirstRecordset is Created.

Can Anyone of You Help Me out. Pls See that the Datagrid works fine(also Refreshes) with a ADODC Control. But I


Need DATAENVIRONMENT control to be used.



Thanx in Advance

Vinay Vekkot

Import/link XLS To Datagrid Using Data Control
How can I import/link excel file to datagrid using data control,
by coding.



Thank's
Jordan Sparta

Error 0 On DataGrid Linked With Ado Data Control
Does anyone know why I would get error 0 every time I touch the datagrid
during runtime(ie/update, etc)....Which library(s) do I have to reference to
use the datagrid and the ado data control?

Any help would be appreciated!! Thanks
Sonia

Automation Error (440) With ADO Data Control & DataGrid
                    Hello -
                    I am using VB6 against a SQL Server 7 db.

                    This is a very simple program whereby the datagrid is populated
                    by Adodc1  without any VB code.

                    I added a Timer control to refresh the data grid every 10
                    seconds   (Adodc1.Refresh)   This works very well.

                    Problem:  The program runs fine, refreshing the grid
                    periodically....  then after running for several minutes
                   (seems to  always be about 4 - 5  minutes)  get the
                   run-time    Automation   error (error 440)

                    The documentation for Error 440 says -" An error occurred
                    while  executing  a method"

                    Well,  the only method being executed is the .Refresh

                    I can only guess that there is a Timeout problem occurring
                    or  the   SQL Server db  is too busy to respond...?

                    I took the default values for Connection Timeout etc when I created
                    the controls.


                    Has anyone had experience with Automation errors?
                    Thanks for any help.
                    John

Insertion Of Data Using Datagrid Control. VB + SQL Server
Hi,
   I have a problem in inserting the new record's data in DataGrid control.
I have got 2 tables. One table has a foreign key referring to the primary key of other table. Now records exist in primary key table and I am displaying the foreign key table in the Datagrid control. The fields displayed are partial for I dont want user to view all the fields of the table. Some to the fields get updated later as per the programming logic. But when I insert new record corresponding to the left out fields an error is displayed stating cannot insert null value.

Plz suggest a possible solution.

 

Unable To Link DataGrid To Data Control
I am using a Jet (Access) database with ADO. I am trying to display the data from my data control in a data grid. When I try adjusting the 'Data Source' property of the data grid, I get the following message "No compatible data source was found for this control. Please add an OLEDB data source such as the Data Environment or Microsoft ADO Data Control to the form or project." I get this message even though my Data Control is already on the same form.

Date Format Using ADO Data Control And DataGrid
When using the DataGrid with the ADO Data control in VB6 to view info from Access 97 databases, all "Date" fields are shown in US format. How do I display dates in UK "dd/mm/yy" format.
(The regional settings in control panel are set correctly for UK dates)
Note: Various Recordsets will have the "Date" field in different field positions.

Clear Content Of Datagrid
I need to clear the content of the data grid when I click cmdAdd.

I have tried:


DataGrid1.ClearFields
DataGrid1.Refresh

but nothing happen. Could someone give me a hint. I did a search and didn't come up with anything.

Clear The Datagrid Record
I use ADO, SSTAB and datagrid. My SSTAB have two items 'LOT' and 'OWNER'.After making the query for owner items, I back to the lot items and back again to owner items, the datagrid of the owner record still there. I try to clear the previous record but fail.How I can clear the record in datagrid control?



VB Code:
Private Sub SSTab1_Click(PreviousTab As Integer)'End IfText1.Text = ""Text2.Text = ""End Sub

Clear Datagrid Contents ...
Dear Friends,

How can I clear the contents of a datagrid?

Margaret

Clear Datagrid Contents ..Help
i use vb6 with ado and Database as access2002 .. with below code i have set the data grid data source to
display all records of CONTRDETAIL Table.

Now in the form load i dont want the datagrid to dispaly any records. so that with addnew i can add a record easily without displaying the earlier records in the datagrid .. How can it be possible ..
Can anyone Help .. Plssssssssssssssssss. with some suggesstion

Private Sub Form_Load()
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=TEST"
cn.Open
QUERY = "SELECT * FROM CONTRDETAIL"

Set RS = New ADODB.Recordset
With RS
.ActiveConnection = cn
.LockType = adLockOptimistic
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.Source = QUERY
.Open
End With

Set DataGrid1.DataSource = RS

End Sub

Thanks in anticipation

Help Me To Clear DataGrid Cell
Hi All,
Im working on master detailed using datagrids on a windows form. When i try to insert new row in a child table datagrid, all the columns appear (NULL) , ( NULL) like this. But I would like to shoe blank space in taht cell and aloow to enter some thing. Pl help me how can i cheive this
I appreciate any kind of suggestions.
Thanks
Bye

Updating MS Access Table With ADO Data Control From A Datagrid
Hi,

I'm populating a datagrid with the data of a MS access table using ADO Data Control. If I change the datagrid values, its automatically updating the table contents. Is there any property of the ADO data control, so that only on setting that value, the data grid changes should be reflected in the DB & not otherwise.

regards,
narayan

Datagrid Control, Enter Data Like A Excel Sheet
Hello

I have implemented a datagrid which is connected to a database. I want the user to be able to press the tab key to be able update the cells in the grid, and also be able to select certain cells with the mouse and update them as well.

It is possible to have some code on how to do this.

Many thanks in advance

Steve

Particular Data Should Transfer From Datagrid 6.0 Control To An Excel Sheet
particular data should transfer from datagrid 6.0 control to an Excel sheet ...?

Clear All Rows From Bound DataGrid In VB6
Hello all.

I have an Accounts Receivable, VB6 application where a main form is bound to a data environment hierarchy command with a child command's records placed in a DataGrid for insert, edit, update and deletion. The database is SQL Server 2000.

Problem: I want the user to be able to rollback or 'undo' a
transaction. Most of this process is working except
when all values are set back for invoice, header, and
detail records and it's clear the the SQL Server has
been updated, the DataGrid still shows the records as
does the recordset that supports the details. I've tried
setting the DataSource property = Nothing, refresh,
nothing seems to work. What is the easiest way to
clear all rows from a DataGrid in this context to bring it
in synch with the database (resynch and requery
methods don't work either)?

Clear Value Of Datagrid After Accessing Files From DB Suing ADO
hey guys.. I'm having a problem on how to clear datagrid items in after accessing records from database. I'm using ADO control. can anyone help me!

Binding A DateTimePicker And/or ListBox To DataGrid To Control/restrict Input Data.
I have a DataGrid control with certain editable columns (some Numeric, some Date/Time fields) for which I would like to control/restrict input data. I want to acheive this by displaying a ListBox control or DateTimePicker control (as appropriate for that column) when a user clicks on the button in the cell.

I can display such controls external to the grid on the Button_Click event of the grid but I would rather have these pickers intrinsic to the grid...sure we've seen these all over the place?

Thanks in advance

Clear Data?
im using winsock and i want to send two SEPARATE blocks of data... this is basically what i have

winsockDialog.SendData "hey"
winsockDialog.SendData "sup"

BUT!!!!! with the Private Sub winsockDialog_DataArrival, it sticks em together! how can i fix this?

thanks,
jared

Help! Clear Data Under List Box????
Hi

I've a list of company name, each company has their specific prod.

I have a combo box to list all companies' name, a list box to list product of company when I select, a "check" command button.

The problem was that for example, I select company A with item A1, A2, then I select other company such as B, the list box does not clear item product from company A (that is A1, A2) but it includes A1, A2 and item product B also ( that means A1, A2, B1, B2 ...), and every time I click on "check" command. It repeat above list

Please advise how I can clear list item product from previous selection and how I can design "check" command in order that every time I click it doesn't repeat the list

Thanks

Don't Clear Data In A Textbox
Hi everyone there, i have a question here. I have a sub below and the output of the data in the txtStatus will be refreshed whenever the command button was pressed. How do i keep the previous generated data in the textbox?
I'm not sure if the data were automatically cleared when the cmd btn was clicked were due to the codings below.
Anyone knows how do i solve this?



VB Code:
Private Sub MAP_DRIVE(Driveletter As String, servername As String, customer As String, validtest As String, program1 As String)    'Function to map the server connetions    Dim fso As New FileSystemObject    Dim strPassword As String    Dim strLocalDriveLetter As String 'New    Dim strNetworkPathName As String 'New        txtStatus = "Mapping in Process..."    Screen.MousePointer = vbHourglass    'strPassword = "flex123"    strLocalDriveLetter = Driveletter 'assing the drive letter    strNetworkPathName = "\" & servername & "" & customer & program1 & "UFLEX"  '& validtest    'MsgBox strNetworkPathName 'show server path    'MsgBox strLocalDriveLetter        If WNetAddConnection(strNetworkPathName, strPassword, strLocalDriveLetter) > 0 Then        'MsgBox "An Error occurred mapping the drive", 16, "Error Message"        'End        txtStatus = "An Error occurred mapping the drive." & vbCrLf & "Mapping Failed."        Screen.MousePointer = vbDefault    Else        'MsgBox txtStatus.Text & ": Drive successfully mapped!", 64, "Information"        txtStatus = "Drive successfully mapped!"        Call unmap_drives(False) 'do display all the mapped servers        Screen.MousePointer = vbDefault    End IfEnd Sub


Thanks alot.

How Do You Clear All The Data In The ListView To Nothing?
How do you clear all the data in the ListView to nothing? I mean,
clear it like the Clear method in the ListBox control...anyone
know?

Clear Data From Access
Hi,

I stuck with this problem. Please somebody, help me.
Code:Open sFileName For Input Access Read As #1
        Line Input #1, Trash
            Do While Not EOF(1)
                ArrayText() = Split(Trash, vbTab)
                    oDatabase.Execute "INSERT INTO list (Site,URL,Log,Output,Report,Email,Zip) VALUES ('" & ArrayText(0) & "','" & ArrayText(1) & "','" & ArrayText(2) & "','" & ArrayText(3) & "','" & ArrayText(4) & "','" & ArrayText(5) & "','" & ArrayText(6) & "')"
                Line Input #1, Trash
This code is to open a text file and copy to mdb. When I re-open any text file, data from the text file will copy into mdb with the current data in mdb.
What I want is, when I re-open a new text file, the data from text file will replace all the current data from mdb, or in other way, clear the current data from mdb and replace by the new data from text file.
Hope somebody can help me coz I need to finish up my project within this week.

Smile always
"Laugh is a medicine for all sickness ...
so plz laugh whatever you do"

HOW TO CLEAR A DATA LIST In VB6
Hi,

HOW TO CLEAR A DATA LIST in VB6

How To Clear Long's Data?
Dear VB City Friends,

Let said, i declare user_login as Long, when i add the user_login's ID to my database, can i know how to clear the ID of user_login. I am trying to put like this:

Code:user_login=""

But it will pop up an error message, can i know how to fix this problem?

Please Help & Many Thanks!

From,
Nicholas

How To Clear Data From MS Flexgrid...
Hi All,

my form had msFlexgrid......
i had a popup for entering record after save click all values from popup will be stored into MS Flexgrid....
so on 1,2,3,....

Suppose on new Button Clicl Event

Values in Flexgrid Rows & Cols Should be Cleared

How do i

Thanks

Clear Control Array
Hi,

I have a grid of 81 command buttons, and when you click one it is set to true (boolean) i want to be able to have a reset button which clears the grid but i cant get it.

I've done a search but only found examples for text boxes and no matter how much fiddling i do i cant convert it to command buttons.

Any help?

Many thanks,

Simon

Clear All Control In Frame
Hi all, need help from any of you guys.

I have 3 frame in 1 form. one of the frame is a ticket reservation which consists of 4 steps. the frame will display step by step guide to book a ticket. my question is how to display the next step once the 'next' button is clicked?

Thanx in advance

Clear ListView Control
Hi There,

Just wondering how I would go about clearing the listview control

I need the same as List1.Clear for listview

Clear Control Array?
I have an array - sABC, composed of a few text boxes. How can I clear the data in all those text boxes simultaneously?

It's probably something really simple like sABC.Clear...

Copyright © 2005-08 www.BigResource.com, All rights reserved