473,386 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Error: Value of type '1-dimensional array of System.Data.Dataset' cannot be converted

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.Page
Protected Sub btnLookup_Load(ByVal sender As Object, ByVal e As System.EventArgs) 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.DataSet = GetData(queryString)
If (ds.Tables.Count > 0) Then
GVCompany.DataSource = ds
GVCompany.DataBind()
Else
lblMessage.Text = "Unable to connect to the database."

End If

End If
End Sub
Function GetData(ByVal queryString As String) As System.Data.DataSet()
Dim ConnectionString As String = ConfigurationManager.ConnectionStrings("Connection String").ConnectionString
Dim ds As New System.Data.DataSet()
Try
Dim connection As New System.Data.SqlClient.SqlConnection(ConnectionStri ng)
Dim adapter As New System.Data.SqlClient.SqlDataAdapter(queryString, 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.Dataset'
cannot be converted to 'System.Data.Dataset'.

I am having so much trouble with this.. help would be so appreciated..

thanks!!!!!
Nov 7 '07 #1
6 9063
Plater
7,872 Expert 4TB
Your function returns an array of dataset
Expand|Select|Wrap|Line Numbers
  1. Function GetData(ByVal queryString As String) As System.Data.DataSet()
  2.  
Try this:
Expand|Select|Wrap|Line Numbers
  1. Function GetData(ByVal queryString As String) As System.Data.DataSet
  2.  
Nov 7 '07 #2
now I am getting this error when I go to the page.




Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 18: End Sub
Line 19: Function GetData(ByVal queryString As String) As System.Data.DataSet
Line 20: Dim ConnectionString As String = ConfigurationManager.ConnectionStrings("Connection String").ConnectionString
Line 21: Dim ds As New System.Data.DataSet
Line 22: Try


Source File: V:\inetpub\wwwroot\WVDODevSite\Switchboard.aspx.vb Line: 20

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
Switchboard.GetData(String queryString) in V:\inetpub\wwwroot\WVDODevSite\Switchboard.aspx.vb :20
Switchboard.btnLookup_Load(Object sender, EventArgs e) in V:\inetpub\wwwroot\WVDODevSite\Switchboard.aspx.vb :8
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832
Nov 7 '07 #3
Plater
7,872 Expert 4TB
Is this the offending line?
Expand|Select|Wrap|Line Numbers
  1. Dim ConnectionString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
  2.  
Nov 7 '07 #4
yes thats the problem
Nov 8 '07 #5
Dim ConnectionString As String = ConfigurationManager.ConnectionStrings("Connection String").ConnectionString




is ("ConnectionString") where I put my connection string??? for example it would look like this:

Dim ConnectionString As String = ConfigurationManager.ConnectionStrings
(Data Source=MLIPSCOMB737; Initial Catalog=BID; Integrated Security = True.ConnectionString

???
Thanks for all your help!!!!
Nov 8 '07 #6
Plater
7,872 Expert 4TB
No, that is where it is referencing the connectionstrings section of your web.config file.
Do you have a connectionstring in there?

Something like:
Expand|Select|Wrap|Line Numbers
  1. <connectionStrings>
  2.    <add name="myconstring" connectionString="Data Source=MLIPSCOMB737; Initial Catalog=BID; Integrated Security = True"/>
  3. </connectionStrings>
  4.  
then you would do:
Expand|Select|Wrap|Line Numbers
  1. Dim ConnectionString As String = ConfigurationManager.ConnectionStrings("myconstring").ConnectionString
  2.  
(I think)
Nov 8 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
1
by: brendang | last post by:
Hi, I am getting the following errors on the schema (on the 'Fund_to' and 'Account_to' elements) in Visual Studio.NET when I try to validate the schema itself. I would greatly apreciate any help...
1
by: FayeC | last post by:
I am getting the following error: Microsoft JET Database Engine error '80040e14' Syntax error (missing operator) in query expression ''FayeC' user_email='whatever@none.com' user_compname='none'...
13
by: ScottM | last post by:
I have run into a problem generating the class file via the WSDL utility. I have a WSDL file that was generated by XMLSpy and is able to be read by the Java code utility, but I get the following...
1
by: JumpingOffPlace | last post by:
Hi, I'm hoping that the wealth of knowledge here can stop me from spinning my wheels on this syntax error for hours. :) Below is the code, and the error I am recieving.... Code: <!DOCTYPE...
5
by: jhurrell | last post by:
I have been having some trouble getting my XSL style sheet to parse correctly. I have some XML outputted from an SQL-Server, that I then need to turn into multiple HTML files. This I have done...
2
by: funktacular | last post by:
Hi - I have some javascript that works when I run it from a server, but I need to run it locally. When I try to execute it locally I get the following error: Error: uncaught exception: Permission...
0
by: msconfused | last post by:
Hello all. I'm hoping that someone can help me solve this error. This is the error that I am getting. Fatal error: Call to a member function on a non-object in /home/paytoo/public_html/prices.php...
6
by: Ahmedhussain | last post by:
Hi there, I m doing work on a gridview and Im getting an error: A potentially dangerous Request.Form value was detected from the client (ctl00$Content$GridView1$ctl03$TextBox1="<span...
1
anfetienne
by: anfetienne | last post by:
i take information from a database and then have the collected values entered into a form with hidden fields. <input type="hidden" name="returnURL" id="returnURL" value="<?php print...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.