Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'instance failure' error while connection string is correct

I have following code on page load event:

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load          con = New SqlConnection("Data Source=14GRAFICALI\\SQLEXPRESS;Initial Catalog=sagar;Integrated Security=True")         '-----------------------fill name ddl------------------------------'          Try              da = New SqlDataAdapter("select EmpName from empMaster_VB", con)             ds = New DataSet()             da.Fill(ds)             For i As Integer = 0 To ds.Tables(0).Rows.Count                  ddlName.Items.Add(ds.Tables(0).Rows(i)(0).ToString())              Next           Catch ex As Exception          End Try          '--------------------------------------------------------------------'           '----------------fill expence-------------------------------------'          Try              da = New SqlDataAdapter("select ExpName from expenceType_VB", con)             ds = New DataSet()             da.Fill(ds)             For i As Integer = 0 To ds.Tables(0).Rows.Count                  ddlExpence.Items.Add(ds.Tables(0).Rows(i)(0).ToString())              Next           Catch ex As Exception          End Try           '---------------------------------------------------------------'        End Sub 

This code is to fill drop downs with names and expence values in database tables.

I am getting 'instance failure' error while executing the code.

I checked one of the answers on stack and checked my connection string. But, my connection string is also correct.

Please help me if anything else is missing in this code.

like image 790
C Sharper Avatar asked Jul 15 '13 09:07

C Sharper


People also ask

What is an instance failure?

Database instance failure occurs when a problem prevents an Oracle database instance from continuing to run.

What is connection string in C#?

Connection String is a normal String representation which contains Database connection information to establish the connection between Database and the Application.


1 Answers

As you got the error "instance failure", that might be the error with your SQL Server instance..

Make sure your SQL Server instance(MSSQLSERVER) is running, where you can check in: Services list. TO get into services list: open run dialog box and type: "services.msc" (without quotes) and hit Enter. That takes you to services management console, where you can check whether your instance in running or not..

If the problem still persists, then try using: Data Source=.\SQLEXPRESS instead.. :)

Happy Coding... :)

like image 131
Vidhya Sagar Reddy Avatar answered Sep 22 '22 09:09

Vidhya Sagar Reddy