Solved

Simple Data Connection Issute

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
IIs block files web.config 6 77
call function 8 41
Log4Net custom Appender not being fired. 5 45
Paging GridView 7 34
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

11 Experts available now in Live!

Get 1:1 Help Now