The IListSource does not contain any data sources
What in the world does that mean?IListSource is an interface that provides functionality to an object to return a list that can be bound to a datasource. A dataset for example implements this interface.
Did you databind your datagrid to a dataset obtained form a query to a database using ADO.NET ? Can you provide a snippet of code showing your commands to hook up the datasource and databind?
It was weird - I did the whole section again, code and controls and it worked. Thanks anyway!
I'm having this problem (The IListSource does not contain any data sources) and I don't know what could be wrong. If I test my SQL Query in SQL Analyzer, it does work fine. Now, when I run the query through my ASP.NET page, it sometimes work and others not, even though is the same query.
Dim connectionString As String = "Server='ServerName';User ID=username; Password=mypassword;database='databasename'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
'Set max num of rows
Dim strSQLMaxRecords as string
If intMaxRecords > 0 Then
strSQLMaxRecords = " TOP " & CStr(intMaxRecords) & " "
Else
strSQLMaxRecords = ""
End If
Dim queryString As String = _
"SELECT " & strSQLMaxRecords & _
" * " & _
" FROM dwidx.dbo.fsc_followup as TFUP" & _
" ,dwidx.dbo.patient_fsc_list as TPFL " & _
" ,dwidx.dbo.patient as TPAT " & _
" WHERE " & _
" (TPFL.id = TFUP.id)" & _
" AND (TFUP.id = TPAT.id)" & _
" AND (TPFL.fsc = TFUP.fsc)" & _
" AND (TPAT.oth_num IS NOT NULL)" & _
" AND (TPAT.del_dt IS NULL)" & _
" AND (TPAT.deact_dt IS NULL)" & _
" AND (TPAT.deceased_indicator IS NULL " & _
" OR TPAT.deceased_indicator = 'N') "
...
...
queryString = queryString & " " & m_strSql
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
'Add Parameters
Call AddSQLParameter("@.FSCNUM",intFscn,dbCommand)
'End Add Parameters
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
lblQuery.Text = queryString
dataAdapter.Fill(dataSet)
'Catch SQLex As System.Data.SqlClient.SqlException
' lblFeedback.Text = "SQL Error: " & SQLex.Message & SQLex.Number & "<br />" & queryString
Catch ex as Exception
lblFeedback.Text = "Fatal error: " & ex.Message
End try
return dataSet
In the OnClick of my button...
DataGrid1.DataSource = GetFSCRecords(intFSCN _
, txtINNM.Text _
, txtINA1.Text _
, txtINA2.Text _
, txtINCTY.Text _
, txtINST.Text _
, txtINZIP.Text _
, txtEFF_DT.Text _
, txtEXP_DT.Text _
, intMaxRecords)
DataGrid1.DataBind() <<<< The error occurs here
Hi !
You can check thedataSet.Tables.Cout > 0 ThenreturndataSetelse return null;
I thinks the DataSet return have Count = 0 .
0 comments:
Post a Comment