Hi ,
i am Atul . i write this code to record of list-box in table, but i am facing an error of sql.
In my table i have to columns id (int) which is primary and auto incremented and email(Varchar(50)).
Error i am facing is -
System.Data.SqlClient.SqlParameterCollection.GetParameter(String parameterName) at System.Data.SqlClient.SqlParameterCollection.get_Item(String parameterName) at contactsInvite.Save_E() in d:\Inetpub\wwwroot\PaypalCSharp\contactsInvite.aspx.cs:line 87
if any one help me with this. public void Save_E()
{
SqlConnection connectionSql = new SqlConnection(Constr);
SqlCommand commandSql = new SqlCommand();
commandSql.Connection = connectionSql;
commandSql.CommandText = "INSERT INTO emailinvite (email) VALUES (@e)";
commandSql.Parameters.Add ("@e",SqlDbType.VarChar ) ;
try
{
connectionSql.Open();
for (int indexCounter = 0; indexCounter < lstContacts.Items.Count; indexCounter++)
{
commandSql.Parameters["email"].Value = lstContacts.Items[indexCounter].Text;
commandSql.ExecuteNonQuery();
}
connectionSql.Close();
}
catch (Exception exceptionMessage)
{
//show error message
Response.Write(" No Request send beacuse of" + exceptionMessage );
}
finally
{
commandSql.Dispose();
connectionSql.Close();
connectionSql.Dispose();
}
}
Regards,
Atul Dhiman
"Necessity is the mother of Invention"