Connecting to a database remotely through VS2005

Discussion in 'ASP .Net' started by axel22@gmail.com, Nov 13, 2006.

  1. Guest

    Ok, I've installed MS Sql Server Express, and I've created a database
    'ProbnaBaza' and a table 'clan' in Management Studio. I tried using the
    database locally through a project in Visual
    Studio. I used the following connection string:

    "Server=.\\SQLEXPRESS;Initial Catalog=clan;Integrated Security=SSPI";

    It worked perfectly.
    Then, I tried using the database by setting an IP address within the
    connectionString,
    but only to be given an error message:

    System.Data.SqlClient.SqlException: An error has occurred while
    establishing a connection to the server. When connecting to SQL Server
    2005, this failure may be caused by the fact that under the default
    settings SQL Server does not allow remote connections. (provider: TCP
    Provider, error: 0 - A connection attempt failed because the connected
    party did not properly respond after a period of time, or established
    connection failed because connected host has failed to respond.)

    Can anyone help?

    Here is my source:

    SqlConnection conn = null;

    private void Form1_Load(object sender, EventArgs e)
    {
    conn = new SqlConnection();
    conn.ConnectionString = "Data Source=89.172.48.15,1433;" +
    "Initial Catalog=clan;Trusted_Connection=False;";
    }

    private void button1_Click(object sender, EventArgs e)
    {
    conn.Open();
    SqlCommand comm = new SqlCommand("SELECT * FROM clan;",
    conn);
    SqlDataReader reader = comm.ExecuteReader();
    while (reader.Read())
    {
    label1.Text += reader[0].ToString() +
    reader[1].ToString()
    + reader[2].ToString() + '\n';
    }
    conn.Close();
    }
    , Nov 13, 2006
    #1
    1. Advertising

  2. Make sure you have a protocol to connect other than Shared Memory using the
    config tool.

    You may also have to turn on SQL Browser

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    http://gregorybeamer.spaces.live.com

    *************************************************
    Think outside the box!
    *************************************************
    <> wrote in message
    news:...
    > Ok, I've installed MS Sql Server Express, and I've created a database
    > 'ProbnaBaza' and a table 'clan' in Management Studio. I tried using the
    > database locally through a project in Visual
    > Studio. I used the following connection string:
    >
    > "Server=.\\SQLEXPRESS;Initial Catalog=clan;Integrated Security=SSPI";
    >
    > It worked perfectly.
    > Then, I tried using the database by setting an IP address within the
    > connectionString,
    > but only to be given an error message:
    >
    > System.Data.SqlClient.SqlException: An error has occurred while
    > establishing a connection to the server. When connecting to SQL Server
    > 2005, this failure may be caused by the fact that under the default
    > settings SQL Server does not allow remote connections. (provider: TCP
    > Provider, error: 0 - A connection attempt failed because the connected
    > party did not properly respond after a period of time, or established
    > connection failed because connected host has failed to respond.)
    >
    > Can anyone help?
    >
    > Here is my source:
    >
    > SqlConnection conn = null;
    >
    > private void Form1_Load(object sender, EventArgs e)
    > {
    > conn = new SqlConnection();
    > conn.ConnectionString = "Data Source=89.172.48.15,1433;" +
    > "Initial Catalog=clan;Trusted_Connection=False;";
    > }
    >
    > private void button1_Click(object sender, EventArgs e)
    > {
    > conn.Open();
    > SqlCommand comm = new SqlCommand("SELECT * FROM clan;",
    > conn);
    > SqlDataReader reader = comm.ExecuteReader();
    > while (reader.Read())
    > {
    > label1.Text += reader[0].ToString() +
    > reader[1].ToString()
    > + reader[2].ToString() + '\n';
    > }
    > conn.Close();
    > }
    >
    Cowboy \(Gregory A. Beamer\), Nov 13, 2006
    #2
    1. Advertising

  3. by default sqlexpress does not allow tcp/ip connects, only local shared
    pipes.

    -- bruce (sqlwork.com)


    <> wrote in message
    news:...
    > Ok, I've installed MS Sql Server Express, and I've created a database
    > 'ProbnaBaza' and a table 'clan' in Management Studio. I tried using the
    > database locally through a project in Visual
    > Studio. I used the following connection string:
    >
    > "Server=.\\SQLEXPRESS;Initial Catalog=clan;Integrated Security=SSPI";
    >
    > It worked perfectly.
    > Then, I tried using the database by setting an IP address within the
    > connectionString,
    > but only to be given an error message:
    >
    > System.Data.SqlClient.SqlException: An error has occurred while
    > establishing a connection to the server. When connecting to SQL Server
    > 2005, this failure may be caused by the fact that under the default
    > settings SQL Server does not allow remote connections. (provider: TCP
    > Provider, error: 0 - A connection attempt failed because the connected
    > party did not properly respond after a period of time, or established
    > connection failed because connected host has failed to respond.)
    >
    > Can anyone help?
    >
    > Here is my source:
    >
    > SqlConnection conn = null;
    >
    > private void Form1_Load(object sender, EventArgs e)
    > {
    > conn = new SqlConnection();
    > conn.ConnectionString = "Data Source=89.172.48.15,1433;" +
    > "Initial Catalog=clan;Trusted_Connection=False;";
    > }
    >
    > private void button1_Click(object sender, EventArgs e)
    > {
    > conn.Open();
    > SqlCommand comm = new SqlCommand("SELECT * FROM clan;",
    > conn);
    > SqlDataReader reader = comm.ExecuteReader();
    > while (reader.Read())
    > {
    > label1.Text += reader[0].ToString() +
    > reader[1].ToString()
    > + reader[2].ToString() + '\n';
    > }
    > conn.Close();
    > }
    >
    bruce barker \(sqlwork.com\), Nov 13, 2006
    #3
  4. Please follow the procedure outlined here :
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

    Doing that will fix your problem.



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en espanol : http://asp.net.do/foros/
    ===================================
    <> wrote in message news:...
    > Ok, I've installed MS Sql Server Express, and I've created a database
    > 'ProbnaBaza' and a table 'clan' in Management Studio. I tried using the
    > database locally through a project in Visual
    > Studio. I used the following connection string:
    >
    > "Server=.\\SQLEXPRESS;Initial Catalog=clan;Integrated Security=SSPI";
    >
    > It worked perfectly.
    > Then, I tried using the database by setting an IP address within the
    > connectionString,
    > but only to be given an error message:
    >
    > System.Data.SqlClient.SqlException: An error has occurred while
    > establishing a connection to the server. When connecting to SQL Server
    > 2005, this failure may be caused by the fact that under the default
    > settings SQL Server does not allow remote connections. (provider: TCP
    > Provider, error: 0 - A connection attempt failed because the connected
    > party did not properly respond after a period of time, or established
    > connection failed because connected host has failed to respond.)
    >
    > Can anyone help?
    >
    > Here is my source:
    >
    > SqlConnection conn = null;
    >
    > private void Form1_Load(object sender, EventArgs e)
    > {
    > conn = new SqlConnection();
    > conn.ConnectionString = "Data Source=89.172.48.15,1433;" +
    > "Initial Catalog=clan;Trusted_Connection=False;";
    > }
    >
    > private void button1_Click(object sender, EventArgs e)
    > {
    > conn.Open();
    > SqlCommand comm = new SqlCommand("SELECT * FROM clan;",
    > conn);
    > SqlDataReader reader = comm.ExecuteReader();
    > while (reader.Read())
    > {
    > label1.Text += reader[0].ToString() +
    > reader[1].ToString()
    > + reader[2].ToString() + '\n';
    > }
    > conn.Close();
    > }
    >
    Juan T. Llibre, Nov 13, 2006
    #4
  5. Guest

    Already enabled shared memory and named pipes.

    As for the link, thnx, i'll look into it!


    Juan T. Llibre je napisao/la:
    > Please follow the procedure outlined here :
    > http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277
    >
    > Doing that will fix your problem.
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en espanol : http://asp.net.do/foros/
    > ===================================
    > <> wrote in message news:...
    > > Ok, I've installed MS Sql Server Express, and I've created a database
    > > 'ProbnaBaza' and a table 'clan' in Management Studio. I tried using the
    > > database locally through a project in Visual
    > > Studio. I used the following connection string:
    > >
    > > "Server=.\\SQLEXPRESS;Initial Catalog=clan;Integrated Security=SSPI";
    > >
    > > It worked perfectly.
    > > Then, I tried using the database by setting an IP address within the
    > > connectionString,
    > > but only to be given an error message:
    > >
    > > System.Data.SqlClient.SqlException: An error has occurred while
    > > establishing a connection to the server. When connecting to SQL Server
    > > 2005, this failure may be caused by the fact that under the default
    > > settings SQL Server does not allow remote connections. (provider: TCP
    > > Provider, error: 0 - A connection attempt failed because the connected
    > > party did not properly respond after a period of time, or established
    > > connection failed because connected host has failed to respond.)
    > >
    > > Can anyone help?
    > >
    > > Here is my source:
    > >
    > > SqlConnection conn = null;
    > >
    > > private void Form1_Load(object sender, EventArgs e)
    > > {
    > > conn = new SqlConnection();
    > > conn.ConnectionString = "Data Source=89.172.48.15,1433;" +
    > > "Initial Catalog=clan;Trusted_Connection=False;";
    > > }
    > >
    > > private void button1_Click(object sender, EventArgs e)
    > > {
    > > conn.Open();
    > > SqlCommand comm = new SqlCommand("SELECT * FROM clan;",
    > > conn);
    > > SqlDataReader reader = comm.ExecuteReader();
    > > while (reader.Read())
    > > {
    > > label1.Text += reader[0].ToString() +
    > > reader[1].ToString()
    > > + reader[2].ToString() + '\n';
    > > }
    > > conn.Close();
    > > }
    > >
    , Nov 14, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John

    Updating site database remotely

    John, Jan 11, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    304
    Miha Markic
    Jan 11, 2004
  2. =?Utf-8?B?Um9ja3k=?=

    Grant Administrative Rights Remotely through ASP.NET

    =?Utf-8?B?Um9ja3k=?=, Dec 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    423
    =?Utf-8?B?Um9ja3k=?=
    Dec 20, 2005
  3. Highlander
    Replies:
    9
    Views:
    2,420
    Al Dunbar
    Dec 7, 2005
  4. SE.Computerguy

    VS2005 connecting to database

    SE.Computerguy, Oct 29, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    286
    SE.Computerguy
    Oct 29, 2007
  5. dave
    Replies:
    4
    Views:
    1,352
    Steve Holden
    Nov 18, 2010
Loading...

Share This Page