演练中的错误:安装时使用自定义操作创建数据库 [英] Error in Walkthrough: Using a Custom Action to Create a Database at Installation

查看:53
本文介绍了演练中的错误:安装时使用自定义操作创建数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完成本教程中给出的所有步骤后,演练:使用自定义操作在安装时创建数据库 [ ^ ]
在安装过程中出现以下错误:
错误1001.对象引用未设置为对象的实例
请帮我...
向我提供您的电子邮件地址,我将发送使用该教程制作的解决方案...请帮助我找出其中的错误...

问候
阿尔潘

[edit]已删除代码块,将链接转换为链接-OriginalGriff [/edit]
[edit]将OP的回复添加到了原始帖子-Naerling [/edit]

代码没有显示任何问题..我按照教程中的给定步骤重新检查了我的步骤,但是我完全按照教程中的说明进行了操作....
虽然我使用c#,但是代码是在vb中给出的,所以我使用了转换器将vb代码更改为c#
这是我用于转换的网站

http://www.developerfusion.com/tools/convert/vb-to-csharp/

在代码中,

after i completed all the steps that is given in this tutorial Walkthrough: Using a Custom Action to Create a Database at Installation[^]
i got the following error in the middle of the installation process :
Error 1001.Object reference not set to an instance of an object
please help me with this...
provide me with your email address and i will send the solution i made with that tutorial...please help me to find out the error in it...

regards
Arpan

[edit]Code block removed, link converted to link - OriginalGriff[/edit]
[edit]Added OP''s reply to the original post - Naerling[/edit]

the code didn''t showed any problem in it..i rechecked my steps with the given steps in the tutorial but i did exactly what stated in the tutorial....
though i use c# but the code was given in vb so i used converter to change the vb code to c#
this is the website i used for the conversion

http://www.developerfusion.com/tools/convert/vb-to-csharp/

In the code,

private void ExecuteSql(string DatabaseName, string Sql)
    {
        System.Data.SqlClient.SqlCommand Command = new System.Data.SqlClient.SqlCommand(Sql, masterConnection);

        // Initialize the connection, open it, and set it to the "master" database
masterConnection.ConnectionString = My.Settings.masterConnectionString;
        Command.Connection.Open();
        Command.Connection.ChangeDatabase(DatabaseName);
        try {
            Command.ExecuteNonQuery();
        } finally {
            // Closing the connection should be done in a Finally block
            Command.Connection.Close();
        }
    }



但由于框架版本兼容问题,我认为这条线不起作用...
masterConnection.ConnectionString = My.Settings.masterConnectionString;
....
它将错误指定为上下文中没有名称"My""
所以我用
更改了代码 masterConnection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings ["dbCustomAction.Properties.Settings.masterConnectionString"].ToString();
添加system.Configuration的引用
所以这段代码没有显示任何问题...
现在我不知道我的问题具体在哪里...



but this line didn''t worked i think due to the framework version compatible issues...
masterConnection.ConnectionString = My.Settings.masterConnectionString;
....
it specified the error as "the name ''My'' is not in the context"
so i changed the code with
masterConnection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["dbCustomAction.Properties.Settings.masterConnectionString"].ToString();
adding a refrence of system.Configuration
so this code didn''t showed any problem...
now i don''t know where specifically my problem resides...
can you now help me with this??

推荐答案

问题是您引用的对象未设置:thumbsup:
没有人会给您发送电子邮件给您解决方案.没有您的更加具体,没有人会回答您的问题.也许您应该再次仔细地完成演练中的所有步骤.
如果您不愿意更精确地指定问题,那么我们不愿意(甚至可以!)也不愿更精确地指定答案.
The problem is that you are referencing to an Object which is not set :thumbsup:
No one is going to email you for the solution. And no one is going to answer your question without you being more specific. Perhaps you should carefully go through all the steps in the walkthrough again.
If you are not willing to more precisely specify the problem then we are not willing (if we even could!) to more precisely specify the answer.


我找到了一个很好的解决方案,可以解决创建问题的可能性.带有设置的数据库....如果有任何机构需要链接,我可以提供给他们
i found a good soln for solving creating a database with the setup.... if any body needs the link i can provide it to them


这篇关于演练中的错误:安装时使用自定义操作创建数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆