是否根据.Net中的应用程序设置使用测试数据或实时数据?
我见过有人设置了两个应用程序设置;一个包含测试数据连接字符串,另一个包含实时数据连接字符串。无论它们指向哪个实际数据库,它们都使用相同的dbml,然后无论何时设置数据上下文,它们都只指定要使用的设置。 我想实现这一点,但想知道是否有好的博客帖子或教程展示如何正确地做到这一点,或者是否有更“开箱即用”的替代方法。基于构建类型?基于构建类型?以下是我使用的:是否根据.Net中的应用程序设置使用测试数据或实时数据?,.net,testing,.net,Testing,我见过有人设置了两个应用程序设置;一个包含测试数据连接字符串,另一个包含实时数据连接字符串。无论它们指向哪个实际数据库,它们都使用相同的dbml,然后无论何时设置数据上下文,它们都只指定要使用的设置。 我想实现这一点,但想知道是否有好的博客帖子或教程展示如何正确地做到这一点,或者是否有更“开箱即用”的替代方法。基于构建类型?基于构建类型?以下是我使用的: Friend Sub connect(ByVal isDebuggerAttached As Boolean) Dim server
Friend Sub connect(ByVal isDebuggerAttached As Boolean)
Dim server As String
Dim dbName As String
If isDebuggerAttached Then
server = "DHSDEV10069\DSD"
Else
server = "dhs10073sql"
End If
dbName = "DSDWorkPlanTracking"
_connect = "Data Source=" & server & ";Database=" & dbName & ";Integrated Security=true"
_connect = _connect & ";Application Name = " & My.Application.Info.AssemblyName
End Sub
在调用类中:
Try
Model.instance.connect(System.Diagnostics.Debugger.IsAttached)
Catch ex As Exception
MsgBox("Sorry, couldn't connect to database " & ex.Message)
End Try
此外,有关帮助/信息:
Private Sub mnuHelpAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHelpAbout.Click
Dim msg As String
Dim appName As String
If My.Application.Info.Title <> "" Then
appName = My.Application.Info.Title
Else
appName = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
End If
msg = appName & vbCrLf & vbCrLf
msg = msg & "Version: " & Application.ProductVersion & vbCrLf & vbCrLf ' the file version displayed in .exe properties. Assembly version is for internal builds and doesn't need to change for one developer.
msg = msg & "User: " & My.User.Name & vbCrLf & vbCrLf
msg = msg & "Connection: " & Model.instance.connection & vbCrLf & vbCrLf
MsgBox(msg, MsgBoxStyle.OkOnly, appName)
End Sub
Private子mnuHelpAbout_Click(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理mnuHelpAbout。单击
作为字符串的Dim msg
将appName设置为字符串
如果My.Application.Info.Title为“”,则
appName=My.Application.Info.Title
其他的
appName=System.IO.Path.GetFileName WithOutExtension(My.Application.Info.AssemblyName)
如果结束
msg=appName&vbCrLf&vbCrLf
msg=msg&“Version:”&Application.ProductVersion&vbCrLf&vbCrLf“文件版本显示在.exe属性中。程序集版本用于内部构建,不需要为一个开发人员更改。
msg=msg&“User:&My.User.Name&vbCrLf&vbCrLf
msg=msg&“连接:”&Model.instance.Connection&vbCrLf&vbCrLf
MsgBox(msg,MsgBoxStyle.OkOnly,appName)
端接头
以下是我使用的:
Friend Sub connect(ByVal isDebuggerAttached As Boolean)
Dim server As String
Dim dbName As String
If isDebuggerAttached Then
server = "DHSDEV10069\DSD"
Else
server = "dhs10073sql"
End If
dbName = "DSDWorkPlanTracking"
_connect = "Data Source=" & server & ";Database=" & dbName & ";Integrated Security=true"
_connect = _connect & ";Application Name = " & My.Application.Info.AssemblyName
End Sub
在调用类中:
Try
Model.instance.connect(System.Diagnostics.Debugger.IsAttached)
Catch ex As Exception
MsgBox("Sorry, couldn't connect to database " & ex.Message)
End Try
此外,有关帮助/信息:
Private Sub mnuHelpAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHelpAbout.Click
Dim msg As String
Dim appName As String
If My.Application.Info.Title <> "" Then
appName = My.Application.Info.Title
Else
appName = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
End If
msg = appName & vbCrLf & vbCrLf
msg = msg & "Version: " & Application.ProductVersion & vbCrLf & vbCrLf ' the file version displayed in .exe properties. Assembly version is for internal builds and doesn't need to change for one developer.
msg = msg & "User: " & My.User.Name & vbCrLf & vbCrLf
msg = msg & "Connection: " & Model.instance.connection & vbCrLf & vbCrLf
MsgBox(msg, MsgBoxStyle.OkOnly, appName)
End Sub
Private子mnuHelpAbout_Click(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理mnuHelpAbout。单击
作为字符串的Dim msg
将appName设置为字符串
如果My.Application.Info.Title为“”,则
appName=My.Application.Info.Title
其他的
appName=System.IO.Path.GetFileName WithOutExtension(My.Application.Info.AssemblyName)
如果结束
msg=appName&vbCrLf&vbCrLf
msg=msg&“Version:”&Application.ProductVersion&vbCrLf&vbCrLf“文件版本显示在.exe属性中。程序集版本用于内部构建,不需要为一个开发人员更改。
msg=msg&“User:&My.User.Name&vbCrLf&vbCrLf
msg=msg&“连接:”&Model.instance.Connection&vbCrLf&vbCrLf
MsgBox(msg,MsgBoxStyle.OkOnly,appName)
端接头