Ryan Turney

Ryan Turney

  • NA
  • 245
  • 208.7k

Info from textbox to database

Oct 12 2007 6:55 PM

Hello everyone, I am having problems getting a simple string from a textbox into a SQL Server Express database. Here is what I have:

protected void Submit_Click(object sender, EventArgs e)

{

string connection = "Data Source=./SQLEXPRESS;AttachDbFilename=C:/Users/Ryan/Documents/Visual Studio 2005/WebSites/MyQuizAJAX/App_Data/QuizSQL.mdf;Integrated Security=False;Connect Timeout=30;User Instance=True;Asynchronous Processing=true";

SqlConnection newCon = new SqlConnection(connection);

newCon.Open();

SqlCommand insertCommand = new SqlCommand("INSERT INTO StatsTable Title VALUES ('test')", newCon);

insertCommand.BeginExecuteNonQuery();

}

The code above should enter "test" into the title column in the statstable but I get an error saying I need to enable my SQL Server accept remote connections, any ideas? Am I even approaching this correctly?


Answers (2)