Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Data.SqlClient;
- namespace FitMe
- {
- public partial class Track : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- string name = regFoodNameTxt.Text;
- int cals = regFoodCalTxt.Text;
- int protein = regFoodProteinTxt.Text;
- int carbs = regFoodCarbsTxt.Text;
- int fat = regFoodFatTxt.Text;
- string sqlstring;
- SqlConnection myConnection = new SqlConnection("Data Source=iskra-laptop\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;Pooling=False");
- try
- {
- myConnection.Open();
- }
- catch(Exception e)
- {
- Console.WriteLine(e.ToString());
- }
- sqlstring = " INSERT INTO FoodsTB (NAME, CALS, PROTEIN, FAT, CARB) VALUES ('" + name + "','" + cals + "','" + protein + "','" + carbs + "', '" + fat + "')";
- SqlCommand myCommand = new SqlCommand(sqlstring, myConnection);
- myCommand.ExecuteNonQuery();
- try
- {
- myConnection.Close();
- }
- catch(Exception e)
- {
- Console.WriteLine(e.ToString());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement