连接字符串正确时出现“实例失败”错误 [英] '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
这段代码是用数据库表中的名称和expence值填充下拉列表。
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.
推荐答案
当您收到错误实例失败时,则可能是您的SQL Server实例出现了错误。.
As you got the error "instance failure", that might be the error with your SQL Server instance..
请确保您的SQL Server实例(MSSQLSERVER)正在运行,您可以在其中签入:服务列表。要进入服务列表:打开运行对话框,然后输入: services.msc(不带引号),然后按Enter。这将带您进入服务管理控制台,在该控制台中,您可以检查实例是否正在运行。.
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..
如果问题仍然存在,请尝试使用:Data Source =。 \SQLEXPRESS代替..:)
If the problem still persists, then try using: Data Source=.\SQLEXPRESS instead.. :)
快乐编码...:)
这篇关于连接字符串正确时出现“实例失败”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!