Hi,
i had bug in getting dataset value from databse. but the corresponsing
value is in null. so it is returns Null value in dataset. it return the
expection and sows the error of like below,
System.NullReferenceException: Object reference not set to an instance of an object.
Here is my code :
DataSet ds = service.GetDataSet("sp_smsinbox", "@action$#!@$@substr", "count$#!@$" + substr);
The substr get the values from application and fetch into dataset. but
the dataset had null value, then it redirectd the error.
page.
Can anyone please help me to achieve this.
Any help will be greatly appreciated.
Thanks
Mubarak
Loading
Jignesh TrivediPosted May 8, 2012, 5:23 AM
In which line you get the error?
It may possible your "ds" is null and you are accessinf ds.Table[0].
kindly provide some info.
thx.
Kunal VaishyaPosted May 8, 2012, 5:11 AM
AL MUBARAKPosted May 8, 2012, 5:01 AM
please check the Getdataset value for this function from given below,
namespace smscmsws
{
public service();
{
public DataSet GetDataSet(string sp, string keys, string values);
}
}
Thanks
Mubarak
Kunal VaishyaPosted May 8, 2012, 4:27 AM
we want GetDataSet Function code to check whats function return to check your problem
so can you send me the code of GetDataSet so we can check it
AL MUBARAKPosted May 8, 2012, 3:47 AM
Here is some sample of my code. please take a look for it.
DataSet ds = service.GetDataSet("sp_smsinbox", "@action$#!@$@substr", "count$#!@$" + substr);
int ct = 0;
if (ds.Tables[0].Rows.Count > 0)
{
lblSMSCount.Text = Convert.ToString(ds.Tables[0].Rows[0]["reccount"]);
lblTotPrice.Text = Convert.ToDouble(ds.Tables[0].Rows[0]["tot_price"]).ToString("#0.000");
ct = (int)ds.Tables[0].Rows[0]["reccount"];
}
Jignesh TrivediPosted May 8, 2012, 2:28 AM
can u please share code of GetDataSet method?
I think this will usefull to resolved issue.
thx.
Kunal VaishyaPosted May 8, 2012, 2:16 AM
if ( service.GetDataSet("sp_smsinbox", "@action$#!@$@substr", "count$#!@$" + substr) != null )
{
DataSet ds = service.GetDataSet("sp_smsinbox", "@action$#!@$@substr", "count$#!@$" + substr);
}
AL MUBARAKPosted May 8, 2012, 2:07 AM
Thanks for your reply, i check DB data's. in the table one field,its returns Null value. but the thing is , i dont have idea, using to solve the issue from creating system.DBNull parameter. Can you please guide me tat how can i solve this issue from DB.
Thanks
Mubarak
Kunal VaishyaPosted May 8, 2012, 12:57 AM
Have you checked that GetDataSet function return some records or blank
may be some problem there is return null value please check return source
Jignesh TrivediPosted May 7, 2012, 11:54 PM
I think you must Initialize data set.
try..
DataSet ds =new Dataset();
ds = service.GetDataSet("sp_smsinbox", "@action$#!@$@substr", "count$#!@$" + substr);
can u plese more info about getdataset method.
hope this help.