Hi,
my code is see below.
string cs = WebConfigurationManager.ConnectionStrings["ForumConnectionString"].ConnectionString;
string insertThread = "INSERT Threads" + "(topicid,subject,replies," + "author,lastpostdate)"
+ "VALUES (@topicid,@subject,@replies," + "@author,@lastpostdate)";
string getThreadID = "SELECT @@IDENTITY";
string insertMessage = "INSERT Messages " + "(threadid,author,date,message)"
+ "VALUES (@threadid,@author,@date,@message)";
SqlConnection con = new SqlConnection(cs);
SqlCommand cmd = new SqlCommand(insertThread, con);
//insert the Thread
cmd.Parameters.AddWithValue("topicid", Request.QueryString["topic"]);
cmd.Parameters.AddWithValue("subject", txtSubject.Text);
cmd.Parameters.AddWithValue("replies", 0);
cmd.Parameters.AddWithValue("author", txtEmail.Text);
cmd.Parameters.AddWithValue("lastpostdate", DateTime.Now);
con.Open();
//get the Thread ID
cmd.CommandText = getThreadID;
string threadid = cmd.ExecuteScalar().ToString();
cmd.ExecuteNonQuery();
//insert the Message
cmd.CommandText = insertMessage;
//cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("threadid", threadid);
cmd.Parameters.AddWithValue("author", txtEmail.Text);
cmd.Parameters.AddWithValue("date", DateTime.Now);
cmd.Parameters.AddWithValue("message", txtMessage.Text);
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("Messages.aspx?topic=" + Request.QueryString["topic"] + "&thread=" + threadid);
}
protected void btnCancel_Click(object sender, EventArgs e)
{
Response.Redirect("Threads.aspx?topic=" + Request.QueryString["topic"]);
} please convert this code into linq to sql.