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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:16:17+00:00 2026-05-25T03:16:17+00:00

Hi I would like to know how I should connect to the external SQL

  • 0

Hi I would like to know how I should connect to the external SQL Server database in C# , .NET ?

For example if I have there parameters :

SQL info

  • Url to get to database (throughout browser also): Sqlweb.companyname.com
  • Database username: username
  • Server: Dcms-xxx
  • Databasename: databaseName
  • Databasepassword: password

?

I know how to connect to internal : Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.AppDomain.CurrentDomain.BaseDirectory + "..\\Files\\MapPlaces\\Database.mdb;";

But what about external ?

I have tried :

 string nowConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Sqlweb.companyname.com;Initial Catalog = databaseName; User Id = Username; Password = Password;";

System.Data.OleDb.OleDbConnection dbcon = new System.Data.OleDb.OleDbConnection(nowConString);

string sql = "SELECT * FROM XXXTable";

dbcon.Open();

System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(sql, dbcon);

System.Data.OleDb.OleDbDataReader reader;

reader = cmd.ExecuteReader();

ScriptStuff.Append("Reader created!<br/>");

while (reader.Read())
{
    string companyName = reader.GetValue(1).ToString();

    ScriptStuff.Append(companyName+"<br/>");

}

Did not work ! Thank you for your help !

Edited from comments:

Yes that was one my mistake, thanks. Since first one was access and YES second is SQL Server. And it is SQL Server 2005. But I am new to .net and all that… I have found first one and second one in that connectionstring.com but I could not find or understand how to use that for this one …

Could you help, and just post hole connection ? Thanks – Vilius 7 mins ago

I mean do I still need to use OleDB ? should there be “Provider=Microsoft.Jet.OLEDB.4.0;” in that connection string ? Where do i post what (server (that Dcms-xxx), or url of the sql server (sqlweb.companyname.com))? THANKS FOR YOUR HELP ! –

  • 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-25T03:16:18+00:00Added an answer on May 25, 2026 at 3:16 am

    I would add a connectionString to my app/web.config.

    <connectionStrings>
        <add name="AspnetdbConnectionString"
            connectionString="Data Source=<databaseadress>;Initial Catalog=<database>;User Id=<user>;Password=password>"
            providerName="System.Data.SqlClient"
        />
    </connectionStrings>
    

    The above example is how you specify an connectionstring for a MSSQL connection, and below a way to use this connectionstring.

     using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["AspnetdbconnectionString"].ConnectionString))
            {
                cn.Open();
                using (SqlCommand cm = cn.CreateCommand())
                {
                    cm.CommandType = CommandType.Text;
                    cm.CommandText = "SELECT * FROM ...";
                    using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
                    {
                        while (dr.Read())
                        {
                            // do stuff
                        }
                    }
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know when I should include external scripts or write them
Would like to know what a programmer should know to become a good at
I would like to know what I should use to compile in C. I
I would like to know practically what kind of Assemblies should I deploy in
Accuracy Vs. Precision What I would like to know is whether I should use
I have a database of all countries and cities, I would like to use
I have a database called MyDB in a Microsoft SQL Server 2008 Express instance
I would like to develop an external website using Facebook Connect instead of an
I have a windows service written in C# .NET framework 3.5 and would like
I am more used to SQL Server and I'd like to know if in

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.