con.Open();
dr = null;
SqlCommand cmd = new SqlCommand("SELECT @@IDENTITY", con);
dr = cmd.ExecuteReader();
while (dr.Read())
try
{
{
LBL.Text = (dr["ID"].ToString());
}
}
I have an error in the red line say
System.IndexOutOfRangeException: DeliveryID
I want to get the new database that just add in on to this page
System.IndexOutOfRangeException: DeliveryID
I want to get the new database that just add in on to this page

Iftikar HussainRank #423 · 5.9K reputationPosted Jul 11, 2013, 6:55 AM EDT
You should try like this
con.Close();
if(data!=null)
Let me know if you need any more help.
Regards,
Iftikar
Tan Kai Kai114 reputationPosted Jul 12, 2013, 12:30 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 12, 2013, 12:42 AM EDT
Regards,
Iftikar
VulpesRank #55 · 29.2K reputationPosted Jul 12, 2013, 1:12 AM EDT
Kunal VaishyaRank #990 · 2K reputationPosted Jul 12, 2013, 1:18 AM EDT
Riyaz AkhtarRank #2,275 · 619 reputationPosted Jul 12, 2013, 1:45 AM EDT
SqlCommand cmd = new SqlCommand("SELECT @@IDENTITY as ID", con);
Riyaz AkhtarRank #2,275 · 619 reputationPosted Jul 12, 2013, 1:49 AM EDT
Tan Kai Kai114 reputationPosted Jul 12, 2013, 5:44 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 12, 2013, 5:59 AM EDT
Regards,
Iftikar
Tan Kai Kai114 reputationPosted Jul 12, 2013, 6:17 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 12, 2013, 6:35 AM EDT
Then in your code do like this
cmd.CommandType=CommandType.StoredProcedure,
int id=Convert.ToIn32(cmd.ExecuteScalar());
use this id in next page as query string like
Response.Redirect("YourNextPage.aspx?Id=" + id.ToString());
Regards,
Iftikar
Tan Kai Kai114 reputationPosted Jul 12, 2013, 6:57 AM EDT
Plus I using SQL IN the VS so got other way
then how to take the id from here Response.Redirect("YourNextPage.aspx?Id=" + id.ToString());
Tan Kai Kai114 reputationPosted Jul 12, 2013, 7:31 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 12, 2013, 10:40 PM EDT
read this article for calling stored procedure from your VS
http://stackoverflow.com/questions/7836766/calling-a-stored-procedure-with-asp-net
http://support.microsoft.com/kb/306574
Regards,
Iftikar
Tan Kai Kai114 reputationPosted Jul 14, 2013, 5:13 AM EDT