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

  • Home
  • SEARCH
  • 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 3999340
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:38:42+00:00 2026-05-20T07:38:42+00:00

i am making a simple c#.net winform application with a form1, which will connect

  • 0

i am making a simple c#.net winform application with a form1, which will connect to sql server.

i want that before establishing a connection to sql server , the application asks the user to enter the login name & password to connect.

for this what should i do:

take the login name & password in two text boxes & pass them the to the connection string
or
should i pass them to the app.config file & then use the string from app.config file in the form1.cs?

will this be ok with the security issues? if not, then what are the other ways of implementing this task?

  • 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-05-20T07:38:42+00:00Added an answer on May 20, 2026 at 7:38 am

    I would do this:

    • use a SqlConnectionStringBuilder component
    • define things like server name, database name etc. from your app.config
    • that component also has two properties for user name and password – fill those from a dialog box where you prompt the user for this information
    • that SqlConnectionStringBuilder then gives you the proper connection string to use for connecting to your SQL Server

    Update:

    My suggestion would be to store the basic connection string like this:

    <configuration>
      <connectionStrings>
         <add name="MyConnStr" 
              connectionString="server=A9;database=MyDB;" />
      </connectionStrings>
    </configuration>
    

    Then load this “skeleton” connection string (which is incomplete – that alone won’t work!) into your SqlConnectionStringBuilder:

    string myConnStr = ConfigurationManager.ConnectionStrings["MyConnStr"].ConnectionString;
    
    SqlConnectionStringBuilder sqlcsb = new SqlConnectionStringBuilder(myConnStr);
    

    Then grab the user name and password from the user in a dialog box and add those to the connection string builder:

    sqlcsb.UserID = tbxUserName.Text.Trim();
    sqlcsb.Password = tbxPassword.Text.Trim();
    

    and then get the resulting, complete connection string from the SqlConnectionStringBuilder:

    string completeConnStr = sqlcsb.ConnectionString;
    
    using(SqlConnection _con = new SqlConnection(completeConnStr))
    {
       // do whatever you need to do here....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple tool that will get a string of MySQL commands and
I'm making a very simple WCF (C#, .NET 4.0) licensing program that automatically emails
I'm making a simple quiz application which has multiple questions. It has no back
I'm making a simple asp.net/c# application and everything with the Oledb worked just fine
I'm making a simple scheduler with C# in .Net. All it does is execute
I'm making a simple form to create polls, therefore I want the possibility to
I'm making a simple remove link with an onClick event that brings up a
I'm making simple image editor by C# winform. I'm trouble with make zoom function.
This one should be pretty simple. I am making a non-MVC ASP.NET 2.0 site.
I'm making simple XMPP client using Jabber-Net. To send simple message i'm using a

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.