Groups | Blog | Home
all groups > asp.net building controls > october 2003 >

asp.net building controls : Bind the DataGrid..?


Kent Johnson
10/4/2003 6:00:24 PM
Hi all,

How can I get data to show in a datagrid?
This is what I have tested:
===============================
Dim ConnStr As String
ConnStr = "data source=MyServer;initial catalog=pubs;persist security
info=True;workstation id=LABSERVER;packet size=4096;user id=sa

Dim SQLSelect As String
SQLSelect = "SELECT * FROM Titles"

Dim mySqlConn As New System.Data.SqlClient.SqlConnection(ConnStr)
Dim mySqlDA As New System.Data.SqlClient.SqlDataAdapter(SQLSelect, ConnStr)

Dim myDS As New DataSet()

mySqlConn.Open()
mySqlDA.Fill(myDS)
DataGrid2.DataBind()
mySqlConn.Close()
================================
I get no errormessage.

What can be wrong?

/Kent J.



Kent Johnson
10/4/2003 6:52:23 PM
Teemu,

No, I hadn't done that. That fixed it!
Thanks!

Do you happen to know how I can store the fields in memVar when I retrive
one record from the recordset?

Example:
Field1= strVar1
Field2=strVar2
Field3=strVar3

I'm planning to use those fields for calculations.

I guess I have to loop through the fields somehow.

/Kent J.






[quoted text, click to view]

Teemu Keiski
10/4/2003 9:05:43 PM
Hi,

have you set DataGrid2.DataSource=myDS before binding the grid?

--
Teemu Keiski
MCP, ASP.NET MVP
AspInsiders Member, www.aspinsiders.com
ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com

[quoted text, click to view]

Teemu Keiski
10/5/2003 10:27:35 AM
Yes, you'd need to loop through rows in DataSet (or records in DataReader),
but it depends a bit what kind of calculation you are doing.

--
Teemu Keiski
MCP, ASP.NET MVP
AspInsiders Member, www.aspinsiders.com
ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com

[quoted text, click to view]

AddThis Social Bookmark Button