Iron Speed Technical Forums
Register Latest Topics
 
 
 


Reply
  Author   Comment   Page 1 of 2      1   2   Next
StevenS

Registered:
Posts: 12
Reply with quote  #1 

Alright, I've been having difficulty accessing my custom stored procedures, it seems no matter what I try I get an "Object reference not set to an instance of an object" error.

I'm using C# if that matters.

I noticed that only the ISD automatically generated stored procedures appear in ISD and VS 2010 - is this normal, or could this be why I'm not able to find the reference to the stored procedure in my database?

 

Thanks

mhweiss

Avatar / Picture

MVP Consultant
Registered:
Posts: 569
Reply with quote  #2 
Hello
Can you post the code that calls your stored procedure? Also, is your stored procedure in the same database schema as the Iron Speed stored procedures (i.e., dbo schema)?
Have you added a using clause at the top of the code behind file to reference the System.Data.SqlClient namespace?
Best Regards,
Michael


__________________
michael@occasiosystems.com
http://www.occasiosystems.com
StevenS

Registered:
Posts: 12
Reply with quote  #3 

Hi,

    I didn't have the using System.Data.SqlClient, but I've added it since.  The same error still occurs.

    With regard to the database schema, I'm not entirely sure what you mean (I'm still fairly new to working with databases).  I'm using the Microsoft SQL Server 2008 R2 tool to modify the database.  The Iron Speed stored procedures appear there & have the same dbo.spname as my dbo.retrieve_records stored procedure.  There is a folder in security called schemas, however I am unfamiliar with how to use them.  Would this be where my error is coming from?

    I used the code wizard to generate the code for a gridview object.  I've posted it below.

 

Code:
  
private

System.Data.DataSet CallCustomStoredProcedureForGridView()

{



BaseClasses.Data.StoredProcedureParameter firstParameter =
null;


int checkBit = new int();


if (this.ck_Disposed.Checked)

{
checkBit =0;

}

else

{
checkBit =1;

}


firstParameter = new BaseClasses.Data.StoredProcedureParameter("@CheckActive", checkBit, System.Data.SqlDbType.Bit, System.Data.ParameterDirection.Input);

       
/// Step 2: Add the configured parameters to an array list.

        BaseClasses.Data.StoredProcedureParameter[] parameterList =
new BaseClasses.Data.StoredProcedureParameter[1];

parameterList[0] = firstParameter;


BaseClasses.Data.StoredProcedure myStoredProcedure = null;

/// Step 3: If the stored procedure accepts parameters, use the following
myStoredProcedure = new BaseClasses.Data.StoredProcedure("TEST_DB", "retrieve_records", parameterList);

       
/// Step 4: Run the stored procedure.

       
/// RunQuery() will return true if stored procedure successfully executed. Otherwise, it will return false.

if (myStoredProcedure.RunQuery())

        {


return myStoredProcedure.DataSet;

        }
       
else

        {

return null;

        }
}

 

The above code always returns the object reference error.  When it uses the RunQuery method, false is always returned.

 

Thanks,

Steven

pinbot

Avatar / Picture

MVP Consultant
Registered:
Posts: 964
Reply with quote  #4 

I'm pretty sure the first parameter needs to be same name as your database name from the web.config file.  They usually start with "Database".  Look under ConnectionStrings and then "add name="
 
add name="DatabaseTESTDB1"
 
Whatever the name is should be your first parameter.
 
 

__________________
C. Bryan Patrick II
Iron Speed Designer MVP Consultant
Pseudo Consulting
StevenS

Registered:
Posts: 12
Reply with quote  #5 

Thank you! Thank you! Thank you!

That was the last piece I needed

The proper database name with the additional namespace solved it.

 

Once again, Thank you!

Steven

pinbot

Avatar / Picture

MVP Consultant
Registered:
Posts: 964
Reply with quote  #6 

Glad to hear you got it working.


__________________
C. Bryan Patrick II
Iron Speed Designer MVP Consultant
Pseudo Consulting
Anita

Registered:
Posts: 12
Reply with quote  #7 

I created a new page as per mentioned in the video. It has only one aspx control - button. There is a OnClick function to call the stored procedure. No parameters.

 

The code is as follows:

 

public void ProcessEmployeeTimeDetailReport()
 {
  MyProcessStoredProcedure = new BaseClasses.Data.StoredProcedure(
   "EmployeeTime" ,
   "pEmployeeTimeDetailReport",
   ""
   ;
   
   MyProcessStoredProcedure.RunQuery();
 }

 

aspx button -

OnClick="ProcessEmployeeTimeDetailReport"

  

I cannot see the new created page in the list after building.

 

 

 

 

mhweiss

Avatar / Picture

MVP Consultant
Registered:
Posts: 569
Reply with quote  #8 
Hello
Did you create your page by clicking on the folder you want it contained in and selecting New Page then selecting Blank page? If you did, your page should show up in the application explorer. You can also put a Theme button on the page and set the action property to "Custom". If you do this, you may need to select the button in the Code Documentation tab, right click on it and select Insert Click method. Iron Speed will insert the correct code stub in the proper location for you. You can then add your code to call your custom stored procedure in this Click method.
Best Regards,
Michael

__________________
michael@occasiosystems.com
http://www.occasiosystems.com
Anita

Registered:
Posts: 12
Reply with quote  #9 

I cannot find the code documentation tab. The is a code tab

 

I also cannot see the new page after I run a build. I can see the new page in the  application explorer but I cannot see the page when I access it.

Anita

Registered:
Posts: 12
Reply with quote  #10 
This the step I did

Created a new page

Added Theme Button and set it to custom

In the code tab Iron speed added code for button click

public

void Button_Click(object sender, EventArgs args)

{

this.ProcessStoredProcedure();

// Click handler for Button.

// Customize by adding code before the call or replace the call to the Base function with your own code.

Button_Click_Base(sender, args);

// NOTE: If the Base function redirects to another page, any code here will not be executed.

}

public void ProcessStoredProcedure()
  {
   BaseClasses.Data.StoredProcedureParameter[] parameterList =
   new BaseClasses.Data.StoredProcedureParameter[4];

   parameterList[0] = EmployeeCodeTextBox;
   parameterList[1] = FromDateTextBox;
   parameterList[2] = ToDateTextBox;

   BaseClasses.Data.StoredProcedure myStoredProcedure = null;
 
   myStoredProcedure = new BaseClasses.Data.StoredProcedure("DatabaseEmployeeData", "pEmployeeTimeDetailReport", parameterList);

   myStoredProcedure.RunQuery();
   
  }

 

How do you debug to know if it is executing the stored procedure?


The process Stored Procedure was added to the section 1
venkateshJ

Registered:
Posts: 7
Reply with quote  #11 
Below mentioned 
CallCustomStoredProcedureForGridView()

As per webconfig connection string name using in the parameter stored procedure

add name="DatabaseJVDB1"
myStoredProcedure =newBaseClasses.Data.StoredProcedure("DatabaseJVDB1","retrieve_records", parameterList);
In the development environment returns the proper value. 
Created deployment package and hosted into the server while accessing the function
getting error
Object reference not set to an instance of an object.
Due to this error i am unable to host the developed RESTFull project.

Please assist...



My Code :

public DataSet GetMA(int qpGACoverCode)
{

 

BaseClasses.Data.StoredProcedureParameter firstParameter = null;

 

firstParameter = new BaseClasses.Data.StoredProcedureParameter("@MA_Type", qpGACoverCode, System.Data.SqlDbType.Int, System.Data.ParameterDirection.Input);

BaseClasses.Data.StoredProcedureParameter[] parameterList = new BaseClasses.Data.StoredProcedureParameter[1];
parameterList[0] = firstParameter;

 

BaseClasses.Data.StoredProcedure myStoredProcedure;// = null;

myStoredProcedure = new BaseClasses.Data.StoredProcedure("DatabaseJVDB1", "spMOMAGetByKey", parameterList); 

// Use RunQuery or RunNonQuery. RunQuery is used when a set of records is being returned. RunNonQuery is used when one or more values are returned through output parameters.
try
{
if (myStoredProcedure.RunQuery())
{
return (myStoredProcedure.DataSet);
}
else
{
return null;
}
}
catch
{
return null;
}
}

 

<connectionStrings>
<add name="DatabaseJVDB1" connectionString="Data Source=JV;Database=JVDB;Trusted_Connection=no;User Id=xx;Password=xxxxxx" providerName="System.Data.SqlClient" />
</connectionStrings>

 
JimiJ

Avatar / Picture

MVP Developer
Registered:
Posts: 1,958
Reply with quote  #12 
Were you able to connect using MS Server Management Studio to the remote database? 
__________________

  Jaime Jegonia
[jts_logo]

Iron Speed MVP Developer
 

". . . and whoever sows generously will also reap generously" 2 Cor 9:6

venkateshJ

Registered:
Posts: 7
Reply with quote  #13 
Yes. We can connect through MS Management Studio if we have dedicated IP for the remote database. 
JimiJ

Avatar / Picture

MVP Developer
Registered:
Posts: 1,958
Reply with quote  #14 
Are you using shared IP in the hosted server?
Is your development DB is exactly having the same schema with your production DB?

__________________

  Jaime Jegonia
[jts_logo]

Iron Speed MVP Developer
 

". . . and whoever sows generously will also reap generously" 2 Cor 9:6

venkateshJ

Registered:
Posts: 7
Reply with quote  #15 
Trying to deploy in Beta Server  [Web and DB]. It's in internal domain. 

Same Beta WebServer
--Provider is http://localhost:82
--Consumer is http://localhost:83

Beta DBServer
--schema is going to keep the same in Production.

Before going to production, it should work in Beta environment.  Please assist, running the application through Ironspeed or Visual Studio 2015. Retrieving data successfully through the user stored procedure.
Prepared deployment package and hosted into Beta environment, configured an above-mentioned port in Same Beta WebServer.

Followed as per iron speed hosting procedure.  

Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.

Download Iron Speed Designer

Terms of Service Privacy Statement