我遇到的问题是,当我在vb.net中开发我的应用程序的安装文件时,数据库文件将不会附加到它,作为一个解决方案,我希望创建数据库@首次运行应用程序通过以下代码
Dim myCommand As String
Dim myConnectionString As SqlConnection = New SqlConnection("Data Source=(local)\SQLEXPRESS;Initial Catalog=soft_billing;Integrated Security=True;Pooling=False")
myCommand = "CREATE database soft_billing"
Dim cmd As SqlCommand = New SqlCommand(myCommand, myConnectionString)
Try
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
Catch
MsgBox(" Already installed database", MsgBoxStyle.Critical, " MaS InfoTech- Warning")
End Try
它不会生成所需的数据库, 请帮助我,谢谢你的推荐
答案 0 :(得分:0)
Dim myCommand As String
Dim myConnectionString As SqlConnection = New SqlConnection("Data Source=(local)\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;Pooling=False")
myCommand = "CREATE database soft_billing"
Dim cmd As SqlCommand = New SqlCommand(myCommand, myConnectionString)
Try
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
Catch
MsgBox(" Already installed database", MsgBoxStyle.Critical, " MaS InfoTech- Warning")
End Try