我真是用的changeDatabase这个方法,也是master,程序执行的时候一点错也没有报,但是那个执行根本没有结果,在master看不到自己写的过程,只有我要的表。
//执行的.txt文件
CREATE PROCEDURE [dbo].AddDB
(
@dtDateCreated datetime,
@strDBName varchar(50)
)
AS
Insert into DataBaseInfo
(
dtDateCreated,strDBName
)
Values
(
@dtDateCreated,
@strDBName
)
//执行的fucntion
Private Sub ExecuteSql(ByVal DatabaseName As String, ByVal Sql As String)
Dim Command As New SqlClient.SqlCommand(Sql, sqlConnection1)
Command.Connection.Open()
Command.Connection.ChangeDatabase(DatabaseName)
Try
Command.ExecuteNonQuery()
Finally
' Finally, blocks are a great way to ensure that the connection
' is always closed.
Command.Connection.Close()
End Try
End Sub