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.
Database instance failure occurs when a problem prevents an Oracle database instance from continuing to run.
Connection String is a normal String representation which contains Database connection information to establish the connection between Database and the Application.
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... :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With