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

Populating a DataGrid

Hi all. I hope this is the right group

I am trying to populate a datagrid on an ASP.NET page from a MySQL table
using the .NET connector (ByteFX). But for the life of me, I just cannot
work it out. Can someone tell me what I am doing wrong? What I want is to
click a button and the contents of the table from the DB appears in the
DataGrid on my ASP page.

I tried to follow an example on the web and I just got lost. I have posted
my code below.

Dim ConnStr As String

ConnStr = "server=localhost; user
id=test;password=password;database=documents;pooli ng=false"

Try

Dim TextConn As New MySqlConnection(ConnStr)
Dim TableAdaptor As New MySqlDataAdapter
'Dim CommBuild As New MySqlCommandBuilder
Dim TextDataTable As New DataTable

TextConn.Open()

TableAdaptor = New MySqlDataAdapter("SELECT * FROM daniel",
TextConn)

'CommBuild = New MySqlCommandBuilder(TableAdaptor)

TableAdaptor.Fill(TextDataTable)

TextGrid.DataSource = TextDataTable

IDBox.Text = TextGrid.Items.Count
'TitleBox.Text = TextDataTable.Columns.Count
BodyBox.Text = "Success"

Catch ex As Exception

BodyBox.Text = ex.Message

End Try
Thanks.

--

Bob

--------------------------------------
I'll have a B please Bob.
Nov 19 '05 #1
4 1210
What is the error you are getting?

"Bob Hollness" <bo*@blockbuster.com> wrote in message
news:ew***************@TK2MSFTNGP09.phx.gbl...
Hi all. I hope this is the right group

I am trying to populate a datagrid on an ASP.NET page from a MySQL table
using the .NET connector (ByteFX). But for the life of me, I just cannot
work it out. Can someone tell me what I am doing wrong? What I want is
to click a button and the contents of the table from the DB appears in the
DataGrid on my ASP page.

I tried to follow an example on the web and I just got lost. I have
posted my code below.

Dim ConnStr As String

ConnStr = "server=localhost; user
id=test;password=password;database=documents;pooli ng=false"

Try

Dim TextConn As New MySqlConnection(ConnStr)
Dim TableAdaptor As New MySqlDataAdapter
'Dim CommBuild As New MySqlCommandBuilder
Dim TextDataTable As New DataTable

TextConn.Open()

TableAdaptor = New MySqlDataAdapter("SELECT * FROM daniel",
TextConn)

'CommBuild = New MySqlCommandBuilder(TableAdaptor)

TableAdaptor.Fill(TextDataTable)

TextGrid.DataSource = TextDataTable

IDBox.Text = TextGrid.Items.Count
'TitleBox.Text = TextDataTable.Columns.Count
BodyBox.Text = "Success"

Catch ex As Exception

BodyBox.Text = ex.Message

End Try
Thanks.

--

Bob

--------------------------------------
I'll have a B please Bob.

Nov 19 '05 #2
After
TextGrid.DataSource = TextDataTable

One more line code:

TextGrid.DataBind()

Hope it helps.

Elton Wang
el********@hotmail.com

-----Original Message-----
Hi all. I hope this is the right group

I am trying to populate a datagrid on an ASP.NET page from a MySQL tableusing the .NET connector (ByteFX). But for the life of me, I just cannotwork it out. Can someone tell me what I am doing wrong? What I want is toclick a button and the contents of the table from the DB appears in theDataGrid on my ASP page.

I tried to follow an example on the web and I just got lost. I have postedmy code below.

Dim ConnStr As String

ConnStr = "server=localhost; user
id=test;password=password;database=documents;pool ing=false "
Try

Dim TextConn As New MySqlConnection(ConnStr)
Dim TableAdaptor As New MySqlDataAdapter
'Dim CommBuild As New MySqlCommandBuilder
Dim TextDataTable As New DataTable

TextConn.Open()

TableAdaptor = New MySqlDataAdapter("SELECT * FROM daniel",TextConn)

'CommBuild = New MySqlCommandBuilder (TableAdaptor)
TableAdaptor.Fill(TextDataTable)

TextGrid.DataSource = TextDataTable

IDBox.Text = TextGrid.Items.Count
'TitleBox.Text = TextDataTable.Columns.Count
BodyBox.Text = "Success"

Catch ex As Exception

BodyBox.Text = ex.Message

End Try
Thanks.

--

Bob

--------------------------------------
I'll have a B please Bob.
.

Nov 19 '05 #3
Hi Bob
try this
say that the table on the db is t1
dim con as new sqlconnection(constr)
dim adapter as new sqladapter("select * from t1",con)
dim ds as new dataset()
adapter.fill(ds,"mytable")
yourGrid.datasource(ds)
yourgrid.datamember("mytable")
yourgrid.databind()
this will work
do not open connection with dataadpter

"Bob Hollness" wrote:
Hi all. I hope this is the right group

I am trying to populate a datagrid on an ASP.NET page from a MySQL table
using the .NET connector (ByteFX). But for the life of me, I just cannot
work it out. Can someone tell me what I am doing wrong? What I want is to
click a button and the contents of the table from the DB appears in the
DataGrid on my ASP page.

I tried to follow an example on the web and I just got lost. I have posted
my code below.

Dim ConnStr As String

ConnStr = "server=localhost; user
id=test;password=password;database=documents;pooli ng=false"

Try

Dim TextConn As New MySqlConnection(ConnStr)
Dim TableAdaptor As New MySqlDataAdapter
'Dim CommBuild As New MySqlCommandBuilder
Dim TextDataTable As New DataTable

TextConn.Open()

TableAdaptor = New MySqlDataAdapter("SELECT * FROM daniel",
TextConn)

'CommBuild = New MySqlCommandBuilder(TableAdaptor)

TableAdaptor.Fill(TextDataTable)

TextGrid.DataSource = TextDataTable

IDBox.Text = TextGrid.Items.Count
'TitleBox.Text = TextDataTable.Columns.Count
BodyBox.Text = "Success"

Catch ex As Exception

BodyBox.Text = ex.Message

End Try
Thanks.

--

Bob

--------------------------------------
I'll have a B please Bob.

Nov 19 '05 #4
Don't worry, I solved it.

I changed "TextGrid.DataSource = TextDataTable" to "TextGrid.DataSource =
TextDataTable.DefaultView"

--

Bob

--------------------------------------
I'll have a B please Bob.

"Bob Hollness" <bo*@blockbuster.com> wrote in message
news:ew***************@TK2MSFTNGP09.phx.gbl...
Hi all. I hope this is the right group

I am trying to populate a datagrid on an ASP.NET page from a MySQL table
using the .NET connector (ByteFX). But for the life of me, I just cannot
work it out. Can someone tell me what I am doing wrong? What I want is
to click a button and the contents of the table from the DB appears in the
DataGrid on my ASP page.

I tried to follow an example on the web and I just got lost. I have
posted my code below.

Dim ConnStr As String

ConnStr = "server=localhost; user
id=test;password=password;database=documents;pooli ng=false"

Try

Dim TextConn As New MySqlConnection(ConnStr)
Dim TableAdaptor As New MySqlDataAdapter
'Dim CommBuild As New MySqlCommandBuilder
Dim TextDataTable As New DataTable

TextConn.Open()

TableAdaptor = New MySqlDataAdapter("SELECT * FROM daniel",
TextConn)

'CommBuild = New MySqlCommandBuilder(TableAdaptor)

TableAdaptor.Fill(TextDataTable)

TextGrid.DataSource = TextDataTable

IDBox.Text = TextGrid.Items.Count
'TitleBox.Text = TextDataTable.Columns.Count
BodyBox.Text = "Success"

Catch ex As Exception

BodyBox.Text = ex.Message

End Try
Thanks.

--

Bob

--------------------------------------
I'll have a B please Bob.

Nov 19 '05 #5

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

Similar topics

2
by: Adel | last post by:
Hello guys Does any one know about how to inforce sorting on a specific coloumn in a datagrid before populating it ? Thanks in advance
0
by: Stephen | last post by:
I was wondering if it is possible to take the contents of a row in a datagrid and use an event to copy over the details of the selected row into another datagrid. I'd like to be able to do the...
2
by: Robert | last post by:
I'm sure this is a fairly basic question, but I've been looking all over the web for days for suggestions on how to do this. I've got a datagrid that's bound to a dataset on my form. It includes...
1
by: John | last post by:
Hi all, I have an interesting situation. I have a datagrid I'm currently populating using a dataset but now I need to introduce some extra records into this. I'm unsure of which method to use....
4
by: Paul | last post by:
I sometimes get a timeout error when populating my datagrid, the code is WizardConnection.Open() UpdateCommand.CommandText = "EXECUTE sp_assign_user '" & PhysOffice.SelectedValue & "', '" &...
5
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a...
6
by: fripper | last post by:
I want to populate the cells of a DataGrid at run time. I don't want to bind a database to it I simply want to do some calculations and put results into the grid programmatically. I did this in...
1
by: Mike P | last post by:
I am populating a drop down column in a datagrid on page load. Here is my code : <asp:TemplateColumn> <ItemTemplate> <asp:DropDownList ID="ddlUserName" Font-Name="Verdana" Font-Size="8pt"...
8
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report...
0
by: Eric B. | last post by:
I am populating a DataGrid with many rows. As it is populating I see the scrollbar flying but no rows pop up until it is finished. Is there a way to make each row draw as soon as it is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.