Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8552159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:21:41+00:00 2026-06-11T14:21:41+00:00

I have a problem. I wrote this method for opening sql connection. But it

  • 0

I have a problem. I wrote this method for opening sql connection. But it did not work.
why didn’t this work.

public SqlConnection connection( ) 
{
    string DBName = ConfigurationManager.AppSettings["DBName"].ToString();
    string ServerName = ConfigurationManager.AppSettings["ServerName"].ToString();
    string UserId = ConfigurationManager.AppSettings["UserId"].ToString();
    string DBPassword = ConfigurationManager.AppSettings["DBPassword"].ToString();

    EMVTool.OSSPwdProcessor PwdPass = new EMVTool.OSSPwdProcessor();

    String sClearPwd = "";

    if (DBPassword.Length > 40)
        sClearPwd = PwdPass.DecryptPwd(DBPassword);
    else
        sClearPwd = DBPassword;

    string ConnectionString = "Server=" + ServerName + ";Database =" + DBName + ";UID =" + UserId + ";PWD =" + sClearPwd + ";MultipleActiveResultSets=True;";

    SqlConnection connect = new SqlConnection(ConnectionString);

    return connect;
}

and i am calling the method like that for opening sql connection.

connection().Open();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:21:42+00:00Added an answer on June 11, 2026 at 2:21 pm

    It didn’t work because you opened something but then used different instance afterwards.

    To make it work, assign the function return value to local variable:

    using (SqlConnection  conn = connection())
    {
        conn.Open();
        //rest of code...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've wrote this simple piece of code. And I have a slight problem with
I wrote an application about NFC in android,but I have a problem. When I
I have a problem with the init() method of a standard NSObject. I wrote
I have a problem with deleting my objects. I wrote a delete method which
I have the following method that I wrote for Project Euler - Problem 36
I have this method I wrote as: private void GetReceivedInvoiceTasks(User user, List<Task> tasks) {
I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
This is Uday. I have a problem with the write performance with a small
I have a problem. I wrote example code and I want to build it
I have the following problem. I wrote a query to get the date of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.