Click here to Skip to main content
15,894,539 members
Home / Discussions / C#
   

C#

 
AnswerRe: Help with Prining Pin
Lutosław29-Sep-07 10:51
Lutosław29-Sep-07 10:51 
GeneralRe: Help with Prining Pin
MumbleB29-Sep-07 11:44
MumbleB29-Sep-07 11:44 
GeneralRe: Help with Prining Pin
Lutosław29-Sep-07 12:21
Lutosław29-Sep-07 12:21 
GeneralRe: Help with Prining Pin
Paul Conrad29-Sep-07 13:09
professionalPaul Conrad29-Sep-07 13:09 
GeneralRe: Help with Prining Pin
MumbleB30-Sep-07 3:41
MumbleB30-Sep-07 3:41 
GeneralRe: Help with Prining Pin
Lutosław30-Sep-07 5:33
Lutosław30-Sep-07 5:33 
GeneralRe: Help with Prining Pin
MumbleB30-Sep-07 10:57
MumbleB30-Sep-07 10:57 
Questionbarcode Pin
k36madman29-Sep-07 8:12
k36madman29-Sep-07 8:12 
AnswerRe: barcode Pin
martin_hughes29-Sep-07 10:15
martin_hughes29-Sep-07 10:15 
GeneralRe: barcode Pin
k36madman29-Sep-07 12:02
k36madman29-Sep-07 12:02 
GeneralRe: barcode Pin
martin_hughes29-Sep-07 12:31
martin_hughes29-Sep-07 12:31 
GeneralRe: barcode Pin
k36madman29-Sep-07 14:39
k36madman29-Sep-07 14:39 
GeneralRe: barcode Pin
GuyThiebaut30-Sep-07 8:25
professionalGuyThiebaut30-Sep-07 8:25 
GeneralRe: barcode Pin
k36madman30-Sep-07 10:43
k36madman30-Sep-07 10:43 
QuestionRadio Buttons Pin
picasso229-Sep-07 7:52
picasso229-Sep-07 7:52 
AnswerRe: Radio Buttons Pin
Lutosław29-Sep-07 8:59
Lutosław29-Sep-07 8:59 
QuestionObject reference not set to an instance of an object. Pin
anydie29-Sep-07 7:20
anydie29-Sep-07 7:20 
Whenever i am trying to execute a select statement in a ExecuteScalar() i get the exception from subject: Object reference not set to an instance of an object.

My script is:

public int InsertRecordSP(ref invOrdenes orden)
{
Database db = new Database();

try
{
//abro la coneccion y defino el Store Procedure a utilizar
db.open("insertOrder");

//Ingreso los parametros del Store Procedure
db.setParam("lastOrder", orden.getOrden());

//Ejecuto el Store Procedure
return db.executeScalar();
}
catch (DatabaseException de)
{
log.Error("DatabaseException: " + de.Message);
}
finally
{
db.close();
}
return 0;

}

public Database()
{
// set variables
this.host = ConfigurationSettings.AppSettings.Get("sql-host");
this.user = ConfigurationSettings.AppSettings.Get("sql-user");
this.password = ConfigurationSettings.AppSettings.Get("sql-password");
this.database = ConfigurationSettings.AppSettings.Get("sql-database");

// create the SqlConnection object
String source = "server=" + host + ";uid=" + user + ";pwd=" + password + ";database=" + database;
conn = new SqlConnection(source);
}

public void open(string sprocName)
{
try
{
conn.Open();
scmd = new SqlCommand(sprocName, conn);
}
catch (Exception e)
{
throw new DatabaseException(e.Message);
}
}

public int getParam(string paramName)
{
SqlParameter sqlParam = new SqlParameter();
sqlParam.ParameterName = "@" + paramName;
sqlParam.SqlDbType = SqlDbType.Int;
return (int) sqlParam.Value;
}
public int executeScalar()
{
try
{
return (int)scmd.ExecuteScalar();
}
catch (Exception e)
{
throw new DatabaseException(e.Message);
}
}

What i am doing wrong?



Regards, Diego.
AnswerRe: Object reference not set to an instance of an object. Pin
Luc Pattyn29-Sep-07 7:55
sitebuilderLuc Pattyn29-Sep-07 7:55 
AnswerRe: Object reference not set to an instance of an object. Pin
Guffa29-Sep-07 7:57
Guffa29-Sep-07 7:57 
QuestionxmlTextReader [modified] Pin
jon-8029-Sep-07 6:46
professionaljon-8029-Sep-07 6:46 
Questionimage DBNull Pin
TAREQ F ABUZUHRI29-Sep-07 6:19
TAREQ F ABUZUHRI29-Sep-07 6:19 
AnswerRe: image DBNull Pin
Christian Graus29-Sep-07 11:33
protectorChristian Graus29-Sep-07 11:33 
Question.NET arbitrary precision arithmetic library Pin
thepersonof29-Sep-07 5:55
thepersonof29-Sep-07 5:55 
AnswerRe: .NET arbitrary precision arithmetic library Pin
thepersonof29-Sep-07 8:01
thepersonof29-Sep-07 8:01 
GeneralRe: .NET arbitrary precision arithmetic library Pin
Luc Pattyn29-Sep-07 8:07
sitebuilderLuc Pattyn29-Sep-07 8:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.