protected void Button1_Click(object sender, EventArgs e) { Webservice.WebService1 web = new Webservice.WebService1(); double res = web.add(Convert.ToDouble(TextBox1.Text), Convert.ToDouble(TextBox2.Text)); TextBox3.Text = Convert.ToString(res); string connectionStringTestDb = ConfigurationManager.ConnectionStrings["dbString"].ConnectionString; //string dbString = "Data Source= .\SQLEXPRESS;AttachDbFilename=|DataDirectory|ArithmeticDatabase.mdf; Integrated Security=True;User Instance=True"; SqlConnection myConnection = new SqlConnection(connectionStringTestDb); try { myConnection.Open(); Console.WriteLine("successfully connected database"); string arithOper= "add"; string myquery; myquery = "insert into Arithmetic values('" + TextBox1.Text + "' , '" + TextBox2.Text + "','" + TextBox3.Text+"','"+arithOper+"')"; SqlCommand updatecom = new SqlCommand(myquery, myConnection); updatecom.ExecuteNonQuery(); myConnection.Close(); } catch (SqlException ex) { Console.WriteLine("You failed!" + ex.Message); TextBox3.Text = Convert.ToString(ex.Message); } }
protected void Button1_Click(object sender, EventArgs e) { Webservice.WebService1 web = new Webservice.WebService1(); double res = web.add(Convert.ToDouble(TextBox1.Text), Convert.ToDouble(TextBox2.Text)); TextBox3.Text = Convert.ToString(res); }