473,410 Members | 1,916 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,410 software developers and data experts.

VB.Net Datagrid

Is there a way to bind a datagrid in VB.Net to an ADODB Recordset object? I
have tried:

rs.Open ("SELECT Name FROM tblStaff",connection)

dgTest.SetDataBindings(rs,"")

The recordset is filled but it returns an error at the datagrid
databinding.

TIA :-)
--
ats@home

When an old lady got hit by a truck
I saw a wicked gleam in your eye

Handy utils here: http://www.allenjones.co.uk/utils.htm
Nov 20 '05 #1
5 7077
"Allen" <at**@takeyourhatoff.ntalk.org> schrieb
Is there a way to bind a datagrid in VB.Net to an ADODB Recordset
object? I have tried:

rs.Open ("SELECT Name FROM tblStaff",connection)

dgTest.SetDataBindings(rs,"")

The recordset is filled but it returns an error at the datagrid
databinding.


The documentation of the Datagrid.datasource property lists the variety of
supported data sources.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
On Thu, 3 Jun 2004 20:34:39 +0200, Armin Zingler wrote:
"Allen" <at**@takeyourhatoff.ntalk.org> schrieb
Is there a way to bind a datagrid in VB.Net to an ADODB Recordset
object? I have tried:

rs.Open ("SELECT Name FROM tblStaff",connection)

dgTest.SetDataBindings(rs,"")

The recordset is filled but it returns an error at the datagrid
databinding.


The documentation of the Datagrid.datasource property lists the variety of
supported data sources.


I have read some of it and from this know that it can be bound to an ADODB
recordset. However, it is the second parameter that is causing the error.
The documentation says that the default is an empty string but it fails. I
have also tried putting the table name in there but that generates an error
saying that a Child record cannot be crteated for the table. What should be
put into the second parameter?
--
ats@home

When an old lady got hit by a truck
I saw a wicked gleam in your eye

Handy utils here: http://www.allenjones.co.uk/utils.htm
Nov 20 '05 #3
Data source must implement the 'IEnumerable' interface
like DataTable, DataView, ArrayList, Hashtable but not
the Recordset. First fill DataTable from Recordset and
then bind DataTable to DataGrid.

Try this code:
Dim custDA As New OleDbDataAdapter
Dim dtTerritories As New DataTable
Dim Conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim dgTest as New dataSet

Conn.Open("<-----Use Connection String------
";", "", "", -1) RS.Open("SELECT Name FROM tblStaff", Conn,
ADODB.CursorTypeEnum.adOpenForwardOnly,
ADODB.LockTypeEnum.adLockReadOnly, 1)

custDA.Fill(dtTerritories, RS)
RS.Close()
Conn.Close()
RS = null
Conn = null
dgTest.DataSource = dtTerritories
dgTest.DataBind()

Also, you make like to Reference traditional DataGrid of
VB 6.0 in Windows Form application. Traditional DataGrid
of VB 6.0 may not work in web application.

Good Luck-----Original Message-----
"Allen" <at**@takeyourhatoff.ntalk.org> schrieb
Is there a way to bind a datagrid in VB.Net to an ADODB Recordset object? I have tried:

rs.Open ("SELECT Name FROM tblStaff",connection)

dgTest.SetDataBindings(rs,"")

The recordset is filled but it returns an error at the datagrid databinding.
The documentation of the Datagrid.datasource property

lists the variety ofsupported data sources.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

.

Nov 20 '05 #4
Allen,

You can using the dataadapter make a dataset from a recordset.

I is
datadapter.fill(dataset,recordset,"mytable")

However it has less sence because it is only usable for filling the grid,
not for writing back to the recordset.

When you are able to that take the ADONET approach, which is much easier by
the way too.

Cor

Nov 20 '05 #5
On Thu, 3 Jun 2004 15:29:59 -0700, Shirish Kokate wrote:
Data source must implement the 'IEnumerable' interface
like DataTable, DataView, ArrayList, Hashtable but not
the Recordset. First fill DataTable from Recordset and
then bind DataTable to DataGrid.

Try this code:
Dim custDA As New OleDbDataAdapter
Dim dtTerritories As New DataTable
Dim Conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim dgTest as New dataSet

Conn.Open("<-----Use Connection String------
";", "", "", -1)

RS.Open("SELECT Name FROM tblStaff", Conn,
ADODB.CursorTypeEnum.adOpenForwardOnly,
ADODB.LockTypeEnum.adLockReadOnly, 1)

custDA.Fill(dtTerritories, RS)
RS.Close()
Conn.Close()
RS = null
Conn = null
dgTest.DataSource = dtTerritories
dgTest.DataBind()

Also, you make like to Reference traditional DataGrid of
VB 6.0 in Windows Form application. Traditional DataGrid
of VB 6.0 may not work in web application.

Good Luck


Thanks for that. I will give it a whirl when I get to work :-)

--
ats@home

When an old lady got hit by a truck
I saw a wicked gleam in your eye

Handy utils here: http://www.allenjones.co.uk/utils.htm
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
3
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
5
by: BBFrost | last post by:
Win2000 ..Net 1.1 SP1 c# using Visual Studio Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1 datagrid. I've come to realize that a 'block' of rows highlighted within...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
3
by: CVerma | last post by:
Hi, I have an embedded datagrid within a datalist. I am not able to perfrom paging in the datagrid. Any ideas? Here is my code: Here is my Simplegrid.cs file: using System; using...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
7
by: Dave | last post by:
Are there any add-on products or samples available that can do the following in an vb.net datagrid I want to compare 2 rows in a datagrid - one row from one database and another row for another...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.