Solved

Simple Data Connection Issute

Posted on 2007-04-03
2
202 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
convert html to string 6 34
How to make a GridView cell hyperlinked using C# ? 3 34
Gridview alignment 1 19
mail.To.Add 5 26
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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