M
Michele Fondry via .NET 247
hello.
I have a webform form app in vb.Net that uses a SQL query. I am trying to use the substring function, but get the following error:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A field or property with the name 'description' was not found on the selected datasource.
Source Error:
Line 68: daSearch.Fill(dsSearch, "SearchResults")
Line 69: dgrSearchResults.DataSource = dsSearch.Tables("searchresults").DefaultView
Line 70: dgrSearchResults.DataBind()
I know the field name description is correct, as I can remove the substring from the query and everything works...just my datagrid is too long.
Here is my SQL statement:
Dim daSearch As New SqlDataAdapter("select (substring('description',1,30)),idnum,station,iatanum,inputdate,empname,status from tbTipDetail order by idnum", conn)
daSearch.Fill(dsSearch, "SearchResults")
dgrSearchResults.DataSource = dsSearch.Tables("searchresults").DefaultView
dgrSearchResults.DataBind()
Note: I get the same error with or without the dits around description.
I would appreciate any help or guidance you can offer.
Thank you.
I have a webform form app in vb.Net that uses a SQL query. I am trying to use the substring function, but get the following error:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A field or property with the name 'description' was not found on the selected datasource.
Source Error:
Line 68: daSearch.Fill(dsSearch, "SearchResults")
Line 69: dgrSearchResults.DataSource = dsSearch.Tables("searchresults").DefaultView
Line 70: dgrSearchResults.DataBind()
I know the field name description is correct, as I can remove the substring from the query and everything works...just my datagrid is too long.
Here is my SQL statement:
Dim daSearch As New SqlDataAdapter("select (substring('description',1,30)),idnum,station,iatanum,inputdate,empname,status from tbTipDetail order by idnum", conn)
daSearch.Fill(dsSearch, "SearchResults")
dgrSearchResults.DataSource = dsSearch.Tables("searchresults").DefaultView
dgrSearchResults.DataBind()
Note: I get the same error with or without the dits around description.
I would appreciate any help or guidance you can offer.
Thank you.