I am using VB.NET. I am trying to connect a button so that when it is clicked the gridview pops up the data.
Partial Class Switchboard
Inherits System.Web.UI.P age
Protected Sub btnLookup_Load( ByVal sender As Object, ByVal e As System.EventArg s) Handles btnLookup.Load
If Not Page.IsPostBack Then
Dim queryString As String = "Select CompanyID As CompanyID, Company As Company, [City Location] As [City Location], [Invest Status] As [Invest Status], Phone As Phone, [Fist Name] + ' ' + [Last Name] As Contact From(Companies) "
Dim ds As System.Data.Dat aSet = GetData(querySt ring)
If (ds.Tables.Coun t > 0) Then
GVCompany.DataS ource = ds
GVCompany.DataB ind()
Else
lblMessage.Text = "Unable to connect to the database."
End If
End If
End Sub
Function GetData(ByVal queryString As String) As System.Data.Dat aSet()
Dim ConnectionStrin g As String = ConfigurationMa nager.Connectio nStrings("Conne ctionString").C onnectionString
Dim ds As New System.Data.Dat aSet()
Try
Dim connection As New System.Data.Sql Client.SqlConne ction(Connectio nString)
Dim adapter As New System.Data.Sql Client.SqlDataA dapter(queryStr ing, connection)
adapter.Fill(ds )
Catch ex As Exception
'Message.Text = "Unable to connect to the database."
End Try
Return ds
Try
Catch ex As Exception
End Try
End Function
End Class
The error I am getting is this :
Value of type '1-dimensional array of System.Data.Dat aset'
cannot be converted to 'System.Data.Da taset'.
I am having so much trouble with this.. help would be so appreciated..
thanks!!!!!
Partial Class Switchboard
Inherits System.Web.UI.P age
Protected Sub btnLookup_Load( ByVal sender As Object, ByVal e As System.EventArg s) Handles btnLookup.Load
If Not Page.IsPostBack Then
Dim queryString As String = "Select CompanyID As CompanyID, Company As Company, [City Location] As [City Location], [Invest Status] As [Invest Status], Phone As Phone, [Fist Name] + ' ' + [Last Name] As Contact From(Companies) "
Dim ds As System.Data.Dat aSet = GetData(querySt ring)
If (ds.Tables.Coun t > 0) Then
GVCompany.DataS ource = ds
GVCompany.DataB ind()
Else
lblMessage.Text = "Unable to connect to the database."
End If
End If
End Sub
Function GetData(ByVal queryString As String) As System.Data.Dat aSet()
Dim ConnectionStrin g As String = ConfigurationMa nager.Connectio nStrings("Conne ctionString").C onnectionString
Dim ds As New System.Data.Dat aSet()
Try
Dim connection As New System.Data.Sql Client.SqlConne ction(Connectio nString)
Dim adapter As New System.Data.Sql Client.SqlDataA dapter(queryStr ing, connection)
adapter.Fill(ds )
Catch ex As Exception
'Message.Text = "Unable to connect to the database."
End Try
Return ds
Try
Catch ex As Exception
End Try
End Function
End Class
The error I am getting is this :
Value of type '1-dimensional array of System.Data.Dat aset'
cannot be converted to 'System.Data.Da taset'.
I am having so much trouble with this.. help would be so appreciated..
thanks!!!!!
Comment