I Have an update to my original post. Opt In Newsletter has changed the way they insert email addresses. You not need to use two Stored procedures and also create a GUID for the email address. In addition the Category is stored as a GUID so you will need to find out what it is for the category you want to add the email to ( it is stored in the OptInCategory Table). Hope this helps someone else who needs to do this (create a custom opt in form) James System.Guid guid = System.Guid.NewGuid (); String id = guid.ToString(); System.Data.SqlClient.SqlCommand cmd3; System.Data.SqlClient.SqlCommand cmd2; System.Data.SqlClient.SqlConnection conn3; conn3 = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.AppSettings.Get("SiteSqlServer")); cmd3 = new SqlCommand("OptInEmail_AddOptInEmail", conn3); cmd3.CommandType = CommandType.StoredProcedure; cmd3.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = txtFirstNameST2; cmd3.Parameters.Add("@LastName", SqlDbType.VarChar).Value = txtLastNameST2; cmd3.Parameters.Add("@EmailAddress", SqlDbType.VarChar).Value = EmailST2; cmd3.Parameters.Add("@PortalID", SqlDbType.VarChar).Value = 0; cmd3.Parameters.Add("@OptInEmailID", SqlDbType.VarChar).Value =id; cmd3.Parameters.Add("@IsVerified", SqlDbType.VarChar).Value = -1; cmd3.Parameters.Add("@EmailFormat", SqlDbType.VarChar).Value = 0; try{ conn3.Open(); int rows = cmd3.ExecuteNonQuery(); conn3.Close(); } catch{} cmd2 = new SqlCommand("OptInEmail_AddOptInCategoryEmail", conn3); cmd2.CommandType = CommandType.StoredProcedure; //Need GUID of newsletter category cmd2.Parameters.Add("@guidOptInCatID", SqlDbType.VarChar).Value = "f22aa8a8-ff71-4630-a3ba-9b557965cf9c"; cmd2.Parameters.Add("@OptIn", SqlDbType.VarChar).Value = -1; cmd2.Parameters.Add("@guidOptInID", SqlDbType.VarChar).Value = id; try{ conn3.Open(); int rows2 = cmd2.ExecuteNonQuery(); conn3.Close(); } catch{}
|