本文介绍了如何使用vb.net生成Sql Database脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想生成sqlscript并使用vb.net运行sqlscript任何人都可以告诉我如何执行此操作我使用以下代码但他给我错误:无法连接到服务器..) I want generate sqlscript and run sqlscript using vb.net any one can tell me how to do this i am using following code but he give me error: Failed to connect to server ..)Dim tableFileName As String = "D:\PharmaDbScript.sql"Dim tableText As StringDim srvMgmtServer As Server = New ServerDim srvConn As ServerConnectionDim osqlservers As String = oSQLConnection.ToStringDim objDB As Database = srvMgmtServer.Databases(osqlservers)srvConn = srvMgmtServer.ConnectionContextsrvConn.ServerInstance = SQLServersrvConn.LoginSecure = FalseIf srvConn.LoginSecure = False Then srvConn.Login = "id" srvConn.Password = "password"End IfUsing FileReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(tableFileName) tableText = FileReader.ReadToEndEnd UsingIf tableText <> "" Then objDB.ExecuteNonQuery(tableText)End If 推荐答案 这篇关于如何使用vb.net生成Sql Database脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-26 16:01