Rank: Newbie Groups: Member
Joined: 5/21/2008 Posts: 7
|
Using Visual studio 2008 and SQL Server 2005 express
Script in VB for page Default.ascx ... I have trouble populate a grid1, use this script in vb.....
(Forgive English, are italian, not writer good English.)
examples (version demo DessentialObject)
Dim SQLString As String = "SELECT * FROM WM08 WHERE WM08_Attivo = 'Si'" Dim myConnString As String = "User ID=" & user & ";password=" & pw & ";Initial Catalog=" & dbuser & ";Data Source=" & ipuser & ";" Dim myConnection As New SqlConnection(myConnString) Dim myCommand As New SqlCommand(SQLString, myConnection) ' myConnection.Open() Dim myReader As SqlDataReader = myCommand.ExecuteReader() Dim dt As New DataTable ' If (myReader.HasRows) Then dt.Load(myReader) Grid1.DataSource = dt End If myConnection.Close()
End script examples
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi, Check if you have any columns. Our Grid does not automatically generate columns based on the data source: http://www.essentialobjects.com/ViewDoc.aspx?t=Grid%2fstart.htmlYou don't really need to use a DataTable. You can directly give myReader to Grid1.DataSource. Thanks
|