Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with using Visual web Developer 2005 Express

Status
Not open for further replies.

ASPNETnewbie

Programmer
May 9, 2006
93
US
I am using Visual web developer express for my coding and work. I have a Dataset created in the Codebehind file and I need to bind the information to a Datagrid I have on my .aspx file upon page_load.I have tried debugging and building but for some reason, my dataGrid does not get bound to the Datasource ... Same thing I notice when I use ASP.NET matrix to build my pages. Could someone please tell me what I am missing here????Is there something I need to do before this can work??
 
Please show the code you are using when attempting to bind the data...


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
<script runat="server">

Function Dataget() As System.Data.DataSet
Dim connectionString As String = "server='(local)\SQLEXPRESS'; trusted_connection=true; database='Ch8Case2'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "SELECT [Products].[ProductID], [Products].[ModelNumber], [Products].[ModelName], " & _
"[Products].[Description], [Products].[UnitCost], [Products].[ProductImage], [Pro" & _
"ducts].[Thumbnail] FROM [Products] WHERE ([Products].[CategoryID] = 21)"

Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
Try
dataAdapter.Fill(dataSet)
Catch objerr As Exception
Response.Redirect("Ch10Home.aspx")
End Try
Return dataSet
End Function ' Insert page code here
'

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

DataGrid1.datasource=Dataget()
DataGrid1.Databind()

End Sub

</script>
 
Step through the code and when you get to:
Code:
dataAdapter.Fill(dataSet)
check the DataSet once it has been filled to see if it actually contains any data or not (as if it doesn't, your DataGrid will not display anything).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Nothing seems to be happening. my Database is wide open and the dataGrid itself does not show in anyway that it gets any information from the Database. I have tried debugging and this is what I get....


'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\WebDev.WebServer.EXE', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\WebDev.WebHost\8.0.0.0__b03f5f7f11d50a3a\WebDev.WebHost.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.JScript\8.0.0.0__b03f5f7f11d50a3a\Microsoft.JScript.dll', No symbols loaded.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\chapter11b\709e822b\4f7ce551\App_WebReferences.hpdi9lf3.dll', Symbols loaded.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll', No symbols loaded.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll', No symbols loaded.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\chapter11b\709e822b\4f7ce551\App_Web_pq-arqxo.dll', No symbols loaded.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualBasic\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.dll', No symbols loaded.
'WebDev.WebServer.EXE' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Web.RegularExpressions\2.0.0.0__b03f5f7f11d50a3a\System.Web.RegularExpressions.dll', No symbols loaded.
 
So does the DataSet contain any data or not?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I am sorry but I did not get that information from the Debug information I got. Or maybe I have no clue on how to debug and get information such as that one from the information I have here. Could you please explain what I ought to do instead of what I did???
 
When debugging, set breakpoints on the relevant line(s). Then, step through the code and see what the releavnt object contains.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I am having problems with my server at the moment.. I need to get it fixed but I am working on answering your last question cause I really want this problem over with.
 
Looks correct from what I can tell. First, what happens if you run that query in query analyzer. Do you get a result set?

Next try adding...

Code:
dbCommand.CommandType = CommandType.Text

Also, try taking out the "[" and "]" around the tables and columns (might not make a difference though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top