Click here to Skip to main content
16,016,227 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
[WebMethod]
public static void GetStockLedger()
{
string DBCon = ConfigurationManager.ConnectionStrings["DBConnection"].ToString();
SqlConnection sqlCon = new SqlConnection(DBCon);
sqlCon.Open();
SqlCommand sqlCmd = new SqlCommand("GetInvestorPortfolioList", sqlCon);

//sqlCmd.CommandType = CommandType.StoredProcedure;
//SqlParameter param = new SqlParameter();
//param = sqlCmd.Parameters.Add("@ParamInvestor", SqlDbType.NVarChar);
//param.Direction = ParameterDirection.Input;
//param.Value = "SeqName";
//SqlDataReader data = sqlCmd.ExecuteReader();

sqlCmd.CommandType = CommandType.StoredProcedure;

sqlCmd.Parameters.Add("@ParamInvestor", SqlDbType.VarChar).Value = "01010";
sqlCmd.Parameters.Add("@PortfolioDate", SqlDbType.DateTime).Value = "2013-03-28";
sqlCmd.Parameters.Add("@BusinessDate", SqlDbType.DateTime).Value = "2013-03-28";

SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
DataTable dt = new DataTable();
da.Fill(dt);

Repeater1.DataSource = dt;
Repeater1.DataBind();

sqlCon.Close();
}
Posted

1 solution

Without knowing exactly which line it is complaining about, it isn't that easy to see where your problem might be, but there is only one line that fragment which can be causing a null refenerce exception:
C#
Repeater1.DataSource = dt;
All the lines above it declare objects and set them appropriately, or use variables which are declared and set in the fragment.

So, Repeater1 is null - now you need to look at your other code to find out where it should be loaded with a value, and why it isn't. I can't do that for you - I don't have access to your code! :laugh:
 
Share this answer
 

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