Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
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,
C#
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();
        }
    }


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??
Posted
Updated 5-Jun-11 20:12pm
v3
Comments
Sergey Alexandrovich Kryukov 5-Jun-11 15:25pm    
No issue report. Please, full exception information, lines of the code where it happens.
--SA

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.
 
Share this answer
 
Comments
amsainju 5-Jun-11 21:16pm    
thanks for the suggestion..i will check it out again
amsainju 5-Jun-11 22:00pm    
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();
}
}


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??
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
 
Share this answer
 
Comments
sijjj 14-Aug-12 3:15am    
I would like to know the link for creating database through web setup project

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900