在sql server中生成创建视图和存储过程的sql脚本,我们又生成拥护和角色,就是在安装的时候需要输入数据库用户名和密码才能登陆数据库。你参考这里:http://www.aspxcn.com/dotnetarticle/show.aspx?id=131
注意:
1,你不需要连接数据库,你需要从安装程序那里传递连接数据库的信息。
2,在第17步:CustomActiveData属性即是你再安装程序式的参数,可能有几个,多个用空格隔开比如/p1=[P1] /p2=[P2] ……
3, this.Context.Parameters[key]获取参数的值
4,将你从数据库到处的sql脚本,把GO要改成分号。多交流 :)

解决方案 »

  1.   

    InColdWorld(人间冷暖):
    你真是好人,我的邮箱是
    [email protected]
      

  2.   

    生成数据库及建立视图等等
    1、你先按        http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxwlkWalkthroughUsingCustomActionToCreateDatabaseDuringInstallation.asp           这上面的做好。
    2、将数据库的结构导出,用“;”替换所有有“go",并替换你的sql.txt文件
    3、将如下代码:
    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
    改为:
    Private Sub ExecuteSql(ByVal DatabaseName As String, ByVal Sql As String)
       Dim str = Split(Sql, ";")'将sql.txt中的代码分离
            Dim aa As Integer = 0
            Dim i
            For i = LBound(str) To UBound(str) Step 1
                Dim Command As New SqlClient.SqlCommand()
                Command.CommandText = str(aa)
                Command.Connection = SqlConnection1
                Command.Connection.Open()
                If aa > 3 Then   '在建好了数据库的sql的代码之后
                    Command.Connection.ChangeDatabase(DatabaseName)
                End If
                 Try
                    Command.ExecuteNonQuery()
                Finally
                    Command.Connection.Close()
                End Try
                aa = aa + 1
            Next
    End Sub   就这么简单了,你适当改一下都可以了,有什么问题