label1.Text=textBox1.Text;
string providerName = "System.Data.EntityClient";
string connection = "datasource=students.mssql.somee.com;port=4096;username=someusername;password=somepassword";
SqlConnection Conn=new SqlConnection(connection);
SqlDataAdapter DataAdapter=new SqlDataAdapter();
SqlCommandBuilder cb=new SqlCommandBuilder(DataAdapter);
Conn.Open();
MessageBox.Show("Connected!");
Conn.Close();
Asked
Active
Viewed 61 times
-1

Martijn Pieters
- 1,048,767
- 296
- 4,058
- 3,343
-
4You may have posted your password. you should change that immediately. – DWright May 13 '15 at 04:40
-
Try this http://stackoverflow.com/a/29558863/4513879 – Pradnya Bolli May 13 '15 at 04:50
-
Besides everything else, you should also reference the `SqlClient` - not the `EntityClient` - in your provider name: `string providerName = "System.Data.SqlClient";` – marc_s May 13 '15 at 05:02
2 Answers
3
In your connection string datasource is a single word seperate with a space as below and try.
string connection =
"data source=students.mssql.somee.com;
port=4096;username=*******;password=*******"

Sachu
- 7,555
- 7
- 55
- 94
0
Check your connection string
Remember to try catch
label1.Text=textBox1.Text;
string providerName = "System.Data.EntityClient";
string connection = "datasource=students.mssql.somee.com;port=4096;username=mhs_SQLLogin_1;password=gtwhp7td39";
try{
SqlConnection Conn=new SqlConnection(connection);
SqlDataAdapter DataAdapter=new SqlDataAdapter();
SqlCommandBuilder cb=new SqlCommandBuilder(DataAdapter);
Conn.Open();
MessageBox.Show("Connected!");
Conn.Close();
}catch(Exception ex){
}

anhtv13
- 1,636
- 4
- 30
- 51