0

I get that error when I try to debug my program. Searched for this error but could not really figure it out on my own. Also when I try to connect my database I get this error "error: 26 - Error Locating Server/Instance Specified".

public DataTable ReadData(string st_proc, SqlParameter[] param)
{
    SqlCommand command = new SqlCommand();
    command.CommandType = CommandType.StoredProcedure;
    command.CommandText = st_proc;
    command.Connection = conn;
    if (param != null)
    {
        command.Parameters.AddRange(param);
    }
    SqlDataAdapter db = new SqlDataAdapter(command);
    DataTable dt = new DataTable();
    db.Fill(dt);
    return dt;
}
David
  • 208,112
  • 36
  • 198
  • 279

1 Answers1

0

Looks like you have got the connection string from some else's machine. Here Data Source=(Localdb)\mssqllocaldb; means it is pointing to "[Sql Server Express LocalDB 2014][1]". Make sure you have it installed on you machine. You can also try connecting to DataSource=(Localdb)\v11.0; which is "Sql server express 2012" and use it in your connection string. See if this works.

Community
  • 1
  • 1
vendettamit
  • 14,315
  • 2
  • 32
  • 54