Solved

Simple Data Connection Issute

Posted on 2007-04-03
2
199 Views
Last Modified: 2010-05-18
What is wrong with the below - I am getting the following: Value of type 'System.Data.SqlClient.SqlConnection' cannot be converted to '1-dimensional array of System.Data.SqlClient.SqlConnection'. at this line: GetConnection = ret_conn
   

Protected Function GetConnection() As SqlConnection()

        Dim ret_conn As SqlConnection

        If mCN = String.Empty Then
            ret_conn = New SqlConnection(ConfigurationManager.ConnectionStrings("cn_catteam_dev").ConnectionString) 'Use Default
        Else
            ret_conn = New SqlConnection(mCN)
        End If

        ret_conn.Open()
        GetConnection = ret_conn

    End Function
0
Comment
Question by:tbaseflug
2 Comments
 
LVL 7

Accepted Solution

by:
mem99999 earned 300 total points
ID: 18843981
Try to remove () at first line

Protected Function GetConnection() As SqlConnection

        Dim ret_conn As SqlConnection

        If mCN = String.Empty Then
            ret_conn = New SqlConnection(ConfigurationManager.ConnectionStrings("cn_catteam_dev").ConnectionString) 'Use Default
        Else
            ret_conn = New SqlConnection(mCN)
        End If

        ret_conn.Open()
        GetConnection = ret_conn

    End Function
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 200 total points
ID: 18843991
Try this instead:
   Protected Function GetConnection() As SqlConnection

When you use empty parentheses at the end of a type, it denotes an array.

Bob
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
grab and show facebook pages event calendars 6 65
Handle null when using linq in this line 1 26
SSRS ReportViewer report timeout 7 104
Error on Add method 1 38
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now