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 3317774
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:37:36+00:00 2026-05-17T22:37:36+00:00

there is a way by which we parse any time input given by user…

  • 0

there is a way by which we parse any time input given by user…

here i am taking the input of a connection string from a text file

i am supposed to assume that the user who keeps this string in the text file can be trusted.

but what if he makes a typo a mistake unknowingly, that will cause the coming code to cause exception,

i would like a way to check the string for the correct format, like parse it some way to see if it is the way an connection tring should be, and then possibly use that parsed result.

edit

as requested the sample code i using, and the connection the sqladaptor using

//Connect to a remote instance of SQL Server. 
            Server srv;  
            ServerConnection conContext = new ServerConnection();
            conContext.ServerInstance = @"A-63A9D4D7E7934\SECOND";
            conContext.LoginSecure = false;
            conContext.Login = "sa";
            conContext.Password = "two";
            srv = new Server(conContext);
            Response.Write(srv.Information.Version);





            //Data Source=A-63A9D4D7E7834\SECOND;Initial Catalog=replicate;User ID=sa;Password=***********
  • 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-17T22:37:37+00:00Added an answer on May 17, 2026 at 10:37 pm

    A regular expresion can’t validate an incorrect password, user name, or host name, so it is possible for your user to generate a valid string that will still cause an exception.

    Also, you can’t build a regex that will cover every possible combination of connection arguments.

    The only robust solution, would be to wrap the connection code in a try/catch block and provide an appropriate error message.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to remove the dotted line rectangle, which indicates the keyboard
I want a DateTime variable which is today (any given time of the day)
in Microsoft Access, is there a way which I can programatically set the Confirm
Is there a way to select which TestMethods you want to execute in Visual
I have an assembly. Is there a way to detect which version of .NET
Is there a way in MySQL to select rows which fall on a specific
Is there some way to catch exceptions which are otherwise unhandled (including those thrown
Is there a way to get the path for the assembly in which the
Is there a way in Oracle to select the date on which daylight savings
Is there a way in WPF to Databind to a System.Attribute which is attached

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.