Solved

Simple Data Connection Issute

Posted on 2007-04-03
2
204 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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