Hello everybody!
I have such problem: I'm going to make a little application, which will interact with MSSQL databse, located on remote server. Server is my and I can administrate it remotely. There is MSSQL 2005 there. I created a database there, but can not connect using code from my application. May be I have to change some access rights on server? Here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace my_prg
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Network Library=DBMSSOCN;Data Source=192.168.0.10,2301;database=mydatabase;User id=myuser;Password=pass;";
conn.Open();
DataSet ds = new DataSet();
SqlDataAdapter daDealers = new SqlDataAdapter("SELECT * FROM dealer",conn);
daDealers.Fill(ds);
DataTable tbl = ds.Tables["Table"];
foreach (DataRow row in tbl.Rows)
{
foreach (Object val in row.ItemArray)
{
MessageBox.Show(val.ToString());
}
}
}
}
}
There is a Windows Server 2003 installed on server, myuser - is a windows administrator. When I trying to connect I receive an error that programm can not connect, connection was refused by remote computer. Thank you very much for help.