Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am unable to connect to the database. Can any one please help? Till now I have done:
C#
protected void Page_Load(object sender, EventArgs e) 
{ 
SqlConnection sqlobj = new SqlConnection("Data Source = 182.18.175.64 ; Initial Catalog = TamilnaduForestDept ; Login = ***** ; Password = *****; Integrated Security = True");
string sel = "select Status_CommonID,Status_CommonName,Active_Status,EntryBy,EntryDate from Mst_Status_Common"; 
sqlobj.Open(); 
SqlDataAdapter adp = new SqlDataAdapter(sel, sqlobj); 
DataSet ds = new DataSet(); 
adp.Fill(ds); 
for (int i = 0; i < ds.Tables[0].Rows.Count; i++) 
{ 
ddl_StatusCommon.Items.Add(ds.Tables[0].Rows[i].ItemArray[0].ToString());
 } 
} 
protected void ddl_StatusCommon_SelectedIndexChanged(object sender, EventArgs e) 
{ 
SqlConnection sqlobj = new SqlConnection("Data Source = 182.18.175.64 ; Initial Catalog = TamilnaduForestDept ; Login = ******; Password = *****; Integrated Security = True"); 
string sel = "select Status_CommonId,Status_CommonName,Active_Status,EntryBy,EntryDate from office where Status_CommonId = '" + ddl_StatusCommon.SelectedItem.ToString() + "'"; sqlobj.Open(); 
SqlDataAdapter adp = new SqlDataAdapter(sel, sqlobj); 
DataSet ds = new DataSet(); 
adp.Fill(ds); 
for (int i = 0; i < ds.Tables[0].Rows.Count; i++) 
{ 
ddl_StatusCommon.Items.Add(ds.Tables[0].Rows[i].ItemArray[0].ToString());
 } 
}
Posted
Updated 31-Jan-14 21:54pm
v3
Comments
itsmehaboob 1-Feb-14 2:42am    
Can you connect from sql management tools?
Member 10520129 1-Feb-14 2:45am    
no sir...I can't even connect from there as well
[no name] 1-Feb-14 3:54am    
Is there any error you are getting in this..??

1 solution

Get your connection sorted via SSMS first: that way you can ensure that you have your source, username and password correct before your move to your own code where there are other potential problems. And when you do move to code, don't hard-code your connection string! It needs to be in a configuration file of some description, because it will change - and then you have to recompile and re-issue your source code...

So, try it in SSMS or Visual Studio, and if it doesn't work, start looking at the error message to explain why not.
A quick test with Visual Studio says there is an SQL Server Instance at that IP address, but that the username and Password I tried did not work - predictably enough, because I don't know them and I'm glad to say the admin has changed the default superuser login!

The best guess is that your Username and Password are wrong...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900