473,763 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

bind to data grid

Hi

I have some standard text book type examples of oleDB connections and
routines that populate a list box with data with a query on an Access
database.

What I would like to do is to use a datagrid view instead as the information
in the listbox is very unattractive.

would anyone be kind enough to share some code that can use the result of
the select statement in a datagrid view?

Thansk in advance

doug

Jul 29 '06 #1
1 1796
Function getProductDetai ls() As System.data.Dat aSet

Dim connstr As String = "server=(local) ; user id='sa'; password='hello ';
Database='MyDat abase'"

Dim sqlconn As System.Data.Sql Client.SqlConne ction = New
System.Data.Sql Client.SqlConne ction(connstr)

Dim querystr As String = "select * From ProductDetails"

Dim mycommand As System.Data.Sql Client.SqlComma nd = New
System.Data.Sql Client.SqlComma nd(querystr, sqlconn)

Dim dataAdapter As System.Data.Sql Client.SqlDataA dapter = New
System.Data.Sql Client.SqlDataA dapter(mycomman d)

Dim dataset As System.data.Dat aSet = New System.data.Dat aSet

Try

If sqlconn.State = ConnectionState .Closed Then

sqlconn.Open()

End If

dataAdapter.Fil l(dataset, "ProductDetails ")

Return dataset

Catch ex As Exception

Label1.Text = "Error in retrieving Products Details!"

End Try

End Function

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

'Put user code to initialize the page here

If Not Page.IsPostBack Then

ProductDetails. DataSource = getProductDetai ls() (ProductDetails is my Id
of my datagrid)

ProductDetails. DataBind()

End If

End Sub

"gordon" <go**********@o ptusnet.com.auw rote in message
news:44******** *************** @news.optusnet. com.au...
Hi

I have some standard text book type examples of oleDB connections and
routines that populate a list box with data with a query on an Access
database.

What I would like to do is to use a datagrid view instead as the
information in the listbox is very unattractive.

would anyone be kind enough to share some code that can use the result of
the select statement in a datagrid view?

Thansk in advance

doug

Jul 31 '06 #2

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

Similar topics

1
1717
by: yaniv abo | last post by:
Hello. How can I bind a list of objects to a DataGird? I have a custom collection of Customer class
6
3337
by: Alpha | last post by:
I have several textboxes that I need to chang the text when the selection row is changed in a datagrid. I have the following code. This textbox displayes the initial selection but when I click on different rows in the datagrid, the textbox content doesn't change to reflect the change. How can I address this? Also, If the user change the text in the textbox then how do I refesh the display in the datagrid to reflect the changes? ...
3
3804
by: Dmitry Korolyov [MVP] | last post by:
Is that possible? In other words, I want a dropdown list (and other list-type controls) which appears in edit more of a templated column to be populated with data at the run time. An attempt to do so results in non-existing object error. (Object reference not set to an instance of an object). -- Dmitry Korolyov MVP: Windows Server - Active Directory
0
1404
by: Steve | last post by:
Hi I have a db with 2 tables that I want to bind to a grid depending on a selection in a Dropdownlist Also I want to be able to select a row from the gris to fill some textboxes. The databases are static in that they will not be updated they are just for viewing I have everything working but not to perfection
2
2072
by: Kenneth | last post by:
Hi, I want to make sure I got the easiest way on how to bind a grid's datasource to a datatable. I've made an in-memory datatable Dim dtTotal As DataTable Dim drow As DataRow dtTotal = New DataTable("Total") ' Add two columns
3
9579
by: vineetbatta | last post by:
I have Custom Data class which stores data about single customer and then i store that customer objects in arraylist as shown below. Customer custdata = null; // Custom Data class for 1 customer data. ArrayList ar = new ArrayList(); // To store more than one customer object. for (int x = 0; x < 30; x++) { custdata = new Customer();
2
1780
by: Taha | last post by:
Hi All Can You please Explain To Me How Bind XML Data From WebService To Grid In Vb.Net Thanks
0
2184
by: GMartin | last post by:
I have a pop-up form with a three columned Grid that has checkboxes in a Template Column in the first/left-most column. (The form is to allow users to select "Members" of a group, where they check or clear the boxes next to the potential members they want to add or remove.) The Object Data Source is as follows... <asp:ObjectDataSource ID="odsMembers" runat="server" SelectMethod="GetGroupMembersSelectList"...
1
1297
by: svchosthunter | last post by:
I want to bind a gridview with data table but I need one field as combo box as DataGridviewComboBoxColumn I want that when I bind my grid there should be a combo box in grid which will be binded to another datatable .I want all fields on grid as databound to datatable please help me hyder_master
0
1123
by: Amritha.Datta | last post by:
I want to update MDIChild grid control by setting a datasource. How does it possible from parent form? In other words, I have a data grid control on a MDIChild form. I am binding the data source from datagrid at the time of loading the MDI Child. Now, I need to refresh the data grid when there is a button click happens on the parent form. I do not want to load the complete MDI child again. I just want to update or refresh the data...
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8822
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7366
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.