So... I have 3 textboxes and a Submit button. Here's the code behind:
public void Submit1_onClick(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
DateTime laiks = new DateTime();
conn.ConnectionString = "data source=.;initial catalog=ForumDataBase;integrated security=true;";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "INSERT INTO PostTable(ThreadTitle,PostMessage,UserName) values('" & ThreadTextbox.Value & "','" & PostTextbox.Value & "','" & UserNameTextBox.Value & "')";
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
I don't quite understand SQL syntax used in ASP.NET or wherever so I don't know how to write it properly, but the main problem is that I'm getting this error:
Error 1 The name 'ThreadTextbox' does not exist in the current context
(For all textboxes)
The id's and titles are OK for all textboxes...
So can you tell me what's the problem?
I guess it's because the posts.aspx is not connected with posts.aspx.cs file or something like that, but I've no ideas how to fix it...