You are on page 1of 14

Adding To Database Using Data Grid

I would like to know how to insert multiple rows into an access database from a
datagrid control, or is there any other method for inserting multiple rows by using
another control?
Save Data Into The Database From Ms Flex Grid
Friends,

I want save data into the database from ms flex grid. some rows available in my
grid. save this rows in different records in a database. made this savings in button
click event.

Thanks,
Suresh
Load Data Grid From MySql Database
I want to use a data grid do display and edit items in a data table.

When I try to create a data connection using Server Explorer I get 'Connected OK'
when I test the connection but no table list appears. My database is by the way
located on a server, which may be the problem.

So, my question is:-


Assuming that I can sucessfully open my database using ADO, like:-

Dim Cn As New ADODB.Connection


Dim rs As New ADODB.Recordset
Cn.Open("Provider=MSDASQL;DSN=MyDSN") (or Server;driver;uid;pwd)
rs.Open("select * from Mytable", _
Cn, ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockOptimistic)

How do I then connect the open table to a Data Grid?

Many thanks

Pete
Bulk Transfer Of Data From Grid To Database
Friends,

Is there any effective option for bulk data transfer from a grid to Recordset.
(VB 6.0 and SQL Server2000).
Thanks in advance.

Varun
Update Record In The Data Grid Not Reflect In The Database
Hi All,

I've a question in DataGrid. When i retrieve data into data grid, iallow user to update
or amend the record in the grid. But when i closethe form, the database is not
updated. Is there any coding involve sothat all amended record will be updated to
the table??
Best Regards,
Khai Sze
Populating The Grid With Data Coming From Database And A Variable Which
Increments
im planning to get the data from the database and from a variable that increments...

i dont know how will i be able to display this on the flexgrid..

No name title

1 cathy Accountant

cathy and accountant will cum from the database and no .. would be from
no = no + 1
How To Save The Data From VB Form-grid Into Ms-access Database
Dynamically!
hi!

I had my database called as "Campaign" with one table called "Godzilla" which
contains Details emails of different persons fo different Industry(ex:
health/mechanical/chemical/..etc) in SQL Server..

Now i had a combo box whcih fills the distinct of industries , one flexi grid to show all
the email details of persons industry-wise and one command button("Save").

when i click on combo box ,let us say chemical, all the data corresponding to that
industry from "Godzilla " table are displayed in The Flexi grid.

Imp: Now i wanted to save this flexi grid data into Ms-Access database (Which is in
local system) with dynamical table creation!...for furthet transactions from local
system database...

So plzz tell me how to create a table dynamically in VB to store data in ms-access!

Looking for ur help in this manner...


thanking you,
with best regards,
Sudhakar Reddy,
Systems Engineer, Hyderabad(INDIA)-
Email: sudhacars@yahoo.com
Retrieving Data From Database Into Grid Control [visual Basic]
hi

1.i want to know how to use the DBGrid controls in vb.


2.how to insert the data into the rows
3.can we directly get the records from the data base like access
4.how can i select the rows using Shift+Down key

Let me have the solution soon.


Conecting To A Remote MySQL Database And Displaying The Info In A Data
Grid
Im makign a program with a datagrid to display the Name, Email and various other
fields of a mysql table. How can i have the program connect to the database and
show the information?

Thansk heaps!
Displaying Data In A (data Grid / Flex Grid)
hi i would like to know how to connect to a Access database and display all records in
a flex grid in VB

also i would like to know how to achive the above task from a SQL dadabse using
ADO.. in VB

Plz help me...

Shabbeer
How Do I Search Typed Data In Textbox In Data Grid Column
How do I Search typed data in Textbox in Data Grid Column

on Form load Data From Access TAbles loads into Datagrid

am having Textbox When i Typed Certain Name it should search on Selected Column

thanks
Rajesh
Printing The Contents Of A Data Grid - Data Report? Can Be Packaged?
Dear Friends,

I wish to provide a function to print the content of a data grid like that in Excel,
including grid lines and column headers. But I don't want to use the capture image
method of the grid and send to the Printer object because this is not applicable if the
list is longer then the grid height.

So do I need to use data report? I just notice its existenece in the Designers in the
Project Explorer of VB IDE. Can the project using DataReport be packaegd up as a
standard standalone exe for installing on a new machine?

If special skills or tips are there, please kindly let me know.

Thank you very much for your help


How To Insert Temporary Data In Access(table) Using Data Grid
How to insert data into a table using a data grid.
A little background,i am using SS TAB in my forms i need to hold data temporarly im
my data grid
and then finaly at click it should be inserted in the table.The SS TAB is linked to
ADOC,which is inturn
linked to the table in access.
How To Insert Temporary Data In Access(table) Using Data Grid
How to insert data into a table using a data grid.
A little background,i am using SS TAB in my forms i need to hold data temporarly im
my data grid
and then finaly at click it should be inserted in the table.The SS TAB is linked to
ADOC,which is inturn
linked to table.

Edited by - manav74 on 10/29/2003 1:01:07 AM


SHeridan Data Widgets 2 Data Grid Problem
I have a form VB Tab control on it with three tabs, one each for "Query Setup", "SQL
Display", and "Query Results". Tab # 3 (Query Results) has a Sheridan Data Widgets
2 datagrid on it attached to a standard data control. When the form initially loads the
grid is automatically filled with the fields of the entire database. So far so good,
that's what I want by default.

However, if the creates an SQL on tab #1 (Query Setup) and the statement uses less
fieldnames (columns, ie only First, Middle and Last names instead of all fields) than it
had on the initial load the grid only dislays the first field. The SQL statements are
correct.

I have even tried replacing the Sheridan grid with the VB5 data grid and it works fine
so I must be missing something here, perhaps a setting or something.

My supporvisor wants (likes) the alternate row colors of the Sheridan grid and wants
it to be databounnd so I need to use thia grid.

Any ideas?

Rev. Michael L. Burns


Transfering Data Form A Data Grid To Excel
Hi guys.

I have a program in VB6 which load data from an access table into a data grid, now I
need to trasfer that data in the grid to an excel sheet. How can I do this?.

Thanks in advance
Updating Data Directly In The Cell Of Data Grid
hi, i m wondering whether it is possible to update, insert or delete data directly in the
cell of a data grid? i normally will let d user to click at d data grid and do these
updates on a displaying text box. my user who is a microsoft excel user make a
request that he hope d program will be as similar to excel as possible. i have look
through d forum and didnt find a topic that can solve my problem. by d way, can we
set different background colour or font colour for different columns? thanks~
Inserting Data In Access Using Do While Loop From A Data Grid
how to insert data in access using do while loop from a data grid

Edited by - manav74 on 10/30/2003 11:09:33 PM


Help On Viewing The Searched Data Inside The Data Grid
Can somebody teach me how to view only the searched data within the Data Grid,
removing the other items inside the Data Grid that are not included in the search
that I wrote insde the inputbox....Please add it to my code here:

Dim rsClone As ADODB.Recordset


Dim findpodealername As String
Dim strFind As String

findpodealername = InputBox("Enter DEALER'S NAME:", "FIND DEALER'S NAME")

strFind = "Name = '" & findpodealername & "'"

'create a "copy" of the recordset, used so the current record pointer doesn't change..
Set rsClone = prodorderrs.Clone

With rsClone
'Move to the first record
.MoveFirst
'find the particular string
.find strFind

If Not .EOF Then


'Record has been found...
prodorderrs.Bookmark = .Bookmark 'moves to the found record in the source
r/set
txt_pomonth = .Fields("MONTH")
txt_poday = .Fields("DAY")
txt_poyear = .Fields("YEAR")
txt_podealerID = .Fields("DEALER ID")
txt_poName = .Fields("NAME")
txt_poprodid = .Fields("PRODUCT ID")
txt_pocategory = .Fields("CATEGORY")
txt_poqty = .Fields("QUANTITY")
txt_pocolor = .Fields("COLOR")
txt_posize = .Fields("SIZE")
txt_pocash = .Fields("CASH")
txt_pocredit = .Fields("CREDIT")
txt_poamount = .Fields("AMOUNT")
txt_pobalance = .Fields("BALANCE")
Else
MsgBox "Invalid Dealer Name Entered Or New Order of products"
End If
.Close
End With
Set rsClone = Nothing

End Sub
HOW TO CONNECT DATA REPORT DIRECTLY TO DATA GRID
i need to print the contents of my data grid to data report without using data
environment.. pls help me.. tnx!

Edited by - wildflower_myn on 2/9/2004 9:03:25 PM


Show Data In Data Grid Using Adodb
I want to display data in Data Grid using Adodb

------------------------------------------------------------
Private Sub Command1_Click()
Dim oRs As new ADODB.Recordset

con = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " + App.Path +


"/Northwind.mdb"

oRs.Open "select * from customers", con, adOpenKeyset, adLockOptimistic

Set DataGrid1.DataSource = oRs

DataGrid1.Refresh

End Sub
------------------------------------------------------------

No error when it is run , but the Data Grid is still empty... still no data displayed.

What's wrong with my code ?


Adding Data To The Data Grid Using A Txtbox
I have a form named frmclient that has a datagrid in it which is already connected to
a MS sql server through ADO. My problem is I want to add data in the data grid
using a txt box.

is there a way to do this using only the "adodc.recordsource.addnew" source codes


or do i really have to use stored procedures???
Pass Data From Data Grid To Text Box
Can can i pass Data from data grid to text box while the record in the data grid is
highlighted.
Pass Data From Text Box To Data Grid
Can someone tell me how to pass the data from the text box to the data grid. After
the user press the tab key after the text.
Pls help me
Thks
Import Data From Array To Data Grid
is there any way i can use to import data from an array into the data grid? So that i
can use the data grid as input for my ms chart....
I Want To Display Data With Data Grid Object
hi evrry one
i am new in vb programming
and i want to display data from a database by the use of the datagrid object

i am able to get the data and display it in a combobox


but not with the data grid

to be more clear

in combo box
it was like this
----------->
...
..
.
Dim i
i=0
While Not rs.EOF
Combo1.AddItem rs("ad_id"), i

rs.MoveNext
i=i+1
Wend
...
..
.
<---------
how can i get the same data but in the datagrid

thanx in advance[color=blue][color=blue][color=blue]
Unable To Change Data In The Data Grid
Dear sir/madam;

I have a form with a data grid written with VB version 8176. The project is working
fine with my computer using this version 8176 but when I run the same project at
school. The data grid is not allowing me to change any data in any column in the grid
at all. The version of VB in school is 9899 and have SP5 as well. Could you please
help me resolve this problem. My school project is due in one more week and I have
to get this data grid working. Please help, please!

Thank you for your attention.

Abdul.
Grids And Data Can I Edit Data In A Grid??????
i would like to load data from my sql7 server in to a grid control then click into a cell
and edit the data then save that data back to my sql 7 server can this be done????
Data Grid: How To Enter And Change Data?
Hi, folks!

I've added a Datagrid control to my form and have set its properties like this:
AllowAddNew = false
AllowDelete = false
AllowUpdate = false, on the form load event

There's a button called "Add New", with the following module:


MyDatagrid.AllowAddNew = True
Mydatagrid.AddNewMode
But when I click this button, this error message appears:
Invalid use of property (regarding the 2nd line, property .AddNewMode

There's another button called "Changes", with the module:


MyDataGrid.AllowUpdate = True
MyDataGrid.EditActive
And the same error message appears for the .EditActive property.
What I am doing wrong?
I'd like to allow the user to change or add new records only after clicking the proper
buttons. I've done with another forms, but that's the 1rst. time I work with the
DataGrid Control.

Please, help!
Thanks in advance for any ideas,

Roselene
Data Grid And Moving Inserted Data
Hi all,

I have a data grid that is used for input. When a user enters in a new row and
updates it, I would like to put that information in another control. What event can I
use to do this? I tried afterInsert and that gets fired at the wrong time (when the
user goes to the new row).

Thanks,

Paul
How To Retrieve Data From Data Grid To Another Form
i'm making a database that uses a data grid to find and display the contents of my
database... how can i retrieve a record from my datagrid to textfields in another
form... ??? hehe
How To Edit Data On A Data Grid Control?
Hello! I have a program that display a list of schedules on a data grid control and I'm
trying to edit these data in the data grid? How to do this? thanks
Data Environment With Data Grid And Using Query
Ok, very new at this, and only education I have is with Microsoft books I have read.

So here is what I am trying to do.. I am using Data Environment to connect to my


database in ACCESS. I am also using a datagid to view the table. What I wan to do
is be able to run a query on the database table and show the results in the datagrid.

I am not sure if I am even making any sense here, but hoping someone will have a
answer for me

Thanks
Data Grid And ADODC's Data Source
Hi

I have 4 SQL tables and 4 ADODC's (one for each table) and also have 1 DataGrid
How do I change the datagrid's DataSource without adding a data grid for each sql
table ?

If I change the DataSource, DataGrid's column caption, data Field, col width, col
visible or not, will also
change..... how do I do that?

this is what I have for ONE Sql table:

Private Sub Text4_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then

If IsNumeric(Text4.Text) = False Then


MsgBox "Week number?"

Else
Adodc1.RecordSource = "select * from " & pSqlTbl & " where DATE > 0 AND
weeknum = " & Text4.Text & " and year = " & Text3.Text & ""

If Not Adodc1.Recordset.EOF Then


Adodc1.Refresh
DataGrid1.Refresh
DataGrid1.Visible = True
End If

End If

End If

Any ideas

Thank you

OF
Data Grid Control Is Not Filled With Data
Hi,
I hope someone can help me with this:
I made a class module to allow data grid control to get information from the class
module.
Inside the class module I created I made a connection and recordset to trying to fill
the datagrid control.
Can someone tell me what I did was wrong that my datagrid control is not filled with
data?

Thank you very much!

===================

The code within the form where the data grid control is:

' Bind the DataGrid to the new DataSource datNames


Dim datNames As NamesData ' Class variable
' Set datNames = New NamesData
Set GrReport.DataSource = datNames

===============
Below is the class module
==========

Option Explicit
Const DB_CONNECT = "Provider=SQLOLEDB; Data Source=BSQL; " & _
"Initial Catalog=TestField; User Id=flduser;Password=flduser;AutoTranslate=No"
Private WithEvents rsNames As ADODB.Recordset

Private Sub Class_Initialize()


' Add the names of the new datamember to the DataMember collection
' This allows other objects to see the available DataMembers
Dim dbField As ADODB.Connection

Set dbField = New ADODB.Connection


Dim strSQL As String
Dim rsNames As Recordset
Set rsNames = New ADODB.Recordset

dbField.Open (DB_CONNECT)
strSQL = "select * " & _
" from dbo.Daily_PPR"

rsNames.Open strSQL, dbField, adOpenDynamic, adLockOptimistic

End Sub

Private Sub Class_GetDataMember(ByVal DataMember As String, _


Data As Object)
Set Data = rsNames
End Sub
================
Data Grid, Etc./Data Shape Recordset
Is it possible to bind the datagrid, the old flexgrid, etc. to a "DataShape" language
recordset? I was able to bind them to regular recordsets, but not with the data
shape. I know I could use the Hierarchical flex grid for this, but I don't like the way
that control lays out all of the data horizontally. I'd like to have the initial data grid
show the "Parent" side of the recordset, and then allow the user to click on an item
and have the child/detail information pop up. Thanks in advance.
Change The Data Field In Data Grid
Hi all,

I have an ADODC control, namely Adodc1, having the sql statement as below :

sqlstr = "select to_char(IN_DATETIME,'dd-mm-yyyy hh24:mi:ss'),


, other_field from table1"

and the Adodc1 is bind to DataGrid1.


Upon clicking the IN_DATETIME column header, i wish to sort the recordset by
IN_DATETIME. I use the following codes in the DataGrid1_HeadClick(ByVal ColIndex
As Integer) function:
***************************************************************
strColName = DataGrid1.Columns(ColIndex).DataField
Adodc1.Recordset.Sort = strColName & " DESC"
***************************************************************

However, it gave me error as below whenever i click on the IN_DATETIME column :


****************************************************************
run-time error '3265': Ado could not find the object in the collection corresponding to
the name or ordinal reference requested by the application.
****************************************************************

I believe it is because of the sql i used in Adodc1 as the data field name in Adodc1 is
recognised as :
to_char(IN_DATETIME,'dd-mm-yyyy hh24:mi:ss')

Is there anyway i can set the ADODC recordset field name manually in the code? I
tried :
Adodc.Recordset.Fields(ColIndex) = strColName

but it gave me the following error :


****************************************************************
run-time error '91':
Object variable or With block variable not set
***************************************************************
Due to some reasons, i must use to_char(IN_DATETIME,'dd-mm-yyyy hh24:mi:ss')
in my sql instead of IN_DATETIME.

Can anyone give me some hints how should i go about it? Thanks in advance.
Data Environment && Data Grid
I've gotten so much help from everyone, and here's a new one.

I have DE to an Access database with numerous tables. This is what I want to


happen...

I have a form where users can enter in a name (first or last name) in two separate
text boxes. On clicking a button, the system then searches and then bring up a
datagrid of possible matches. Then the user selects a record from the data grid, it
brings ups the actual record with 50 or so fields.

Problem. How do I get the datagrid to refresh/filter every time a new search is
performed? I tried to filter and get the error
"ARGUMENTS ARE OF THE WRONG TYPE, ARE OUT OF ACCEPTABLE RANGE, OR ARE
IN CONFLICT WITH ONE ANOTHER"

One of the filters strings are:


DE1.rsNameData.Filter = ("LastName LIKE '" & LastName.Text & "%' AND FirstName
LIKE '" & FirstName.Text & "%'")

Any suggestions? I really have come to like the DE and not multiple ADODCs since I
have several tables to work with
Data Grid Data Entry
I am currently creating "cash register" for my school project.
I never see find VB books that imply in using "data grid" as means of data entry. But
when I went to a departemnt sote, I saw the cashier used datagrid (or maybe
something that looks like it) as a way to enter the item code. Now, I started to get
confused, since I couldnt find any resource to lead me in using DataGrid as a way to
entry my data then stored into the database. thank you
Data Environment To ADO In Data Grid
Code:
Private Sub Form_Load()
DE.searcBookCode
DataGrid1.DataMember = "searcbookcode"
DE.rssearcBookCode.Close
End Sub

does anyone know how to convert this code into ADO code in vb6?I used Data
Enviroment (DE) in the code above.I want even a li'l idea how to connect this using
ADO.

thanks a lot
Change Data In Data Grid
Hello Friends,

I am developing one application in which I want to display data in data grid from one
table. Now I want to add one column in which I want to enter data and as per
entered data I want to update values in other columns. Plz can u help me how to do
that using Data Grid? Plz reply soon

Thanks
Data Grid Not Displaying Data
Hi
I have a VB6 app that contains a Datagrid that is to be refreshed by and ADODC
based on the text from a listbox which is stored in a string variable. There are 3
columns in the datagrid that need to be displayed and I have set the widths at
design time and I want these to stay fixed at run time and after the datagrid being
refreshed.

I am using the .HoldFields method and it does just that, however the data is not
displayed in the data grid. If I use the same query with the .ClearFields method then
the column widths are reset by vb but the data is displayed.

Code is

Ado.RecordSource = "Select 3 Columns From Table where ID = ' " & Variable & " ' "
Ado.Refresh

Datagrid.HoldFields
Datagrid.Rebind
DataGrid.Refresh

Has anyone got any ideas?


Data Grid For Data Entry
Hello........
I'm useing Data Grid for data entring. I use coding insted of ADODA data
control. But I can't do any typing (editing) the cellpointer. pls
help me any one who familiya with dara grid

Thanks'
Suchira
Retrieve Data From A Data Grid
I want to let the user search a data grid (column 0) for a vendors ID and return the
vendors faxnumber (column 2).

How do I find the row containing the vendor ID and then return the fax number???
Delete Data From Data Grid Help
hi..i have a data grid which is connected to an ado control..i also have a delete
command button with these codes (taken from a faq from this forum):

Dim varBmk As Variant

For Each varBmk In StudentGrid.SelBookmarks


StudentRecords.Recordset.Bookmark = varBmk
StudentRecords.Recordset.Delete
Next

where clicking on the button deletes records stored..but it can only delete if a row is
selected/highlighted..how can i display a messagebox to tell users to highlight a row
to delete?

<Edit> Text from double-post follows - Metallisoft </Edit>


Quote: hi...i have a datagrid connected to an ado control..currently, i have these
codes which allows me to delete by rows using a command button

Dim varBmk As Variant


Dim a As String

If StudentGrid.SelBookmarks.Count > 0 Then

For Each varBmk In StudentGrid.SelBookmarks


StudentRecords.Recordset.Bookmark = varBmk
StudentRecords.Recordset.Delete
Next
Else
a = MsgBox("There are no records selected", vbOKOnly, "Deletion Error")
End If

i wanna be able to let users know that there are no records in the database using a
msgbox when there isnt any data..how do i do so? also, how can i code first record,
last record, previous and next command buttons to navigate through the grid? and
how i can perform validations after editing and updating data? any help will be really
appreciated. thanks.

Edited by - Metallisoft on 11/14/2006 11:42:56 AM


Can I Get Data Into Text Box From Data Grid
ok i have a data grid on my form and 3 text boxes
can i select from datagrid and the cell i select will appear in text box1 then make
another selection and put in textbox2
cheers
Doug

i know i can copy and past but is there any other way
cheers

vb6 and access 2003


also newbie
may the force be with you

Edited by - dougvcd on 6/25/2005 1:11:53 PM


Entering Data In A Data Grid
There seems to be a lot of different grids to use in VB, so I'm not sure which is best
for my purpose. I want the user to be able to manually add/edit/delete simple text
data directly into the grid. The data will be saved to an Access database via ADO, but
I would prefer to handle the database operations with code.

Is this possible? If so, which grid control would be best suited for this.

Thanks,

Randy
Data Combo And Data Grid
What shall i do if, i select any item (Product Name) from data combo, that item's
information (Product Id, Product Name, Unit Price) is displayed on the data grid?
Besides that, after the information is displayed, how can i enable user to enter the
quantity and the total Price is displayed on the other column?
MSHFlexGrid 2 Things I Want To Edit Data In Grid And 2 I Want To Re
Populate Grid
Ok First I want to Edit the Data in the Grid... Note this is partially setup.

I have it so that I can Edit each cell however, I havent the slightest idea of how to
go about saving the edited row after its edited.

Ok, I have 3 option buttons.... I want to select an option button and it re populate
the grid with a new MDB file. I figure I will need to Close the current open MDB so I
can repopulate the grid... but How to accomplish this is the question

You might also like