public void ChangeWebAppData(WebAppData webAppData) { string userDataInput = ""; string requestedGuid = ""; SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = @"Server=localhost\SQLEXPRESS01;Database=master;Trusted_Connection=True;"; SqlCommand sqlCmd = new SqlCommand(); sqlCmd.CommandType = CommandType.Text; sqlCmd.CommandText = "UPDATE webAppData SET lastModified = " + DateTime.Now + ", userData = " + userDataInput + " WHERE guid =" + requestedGuid; sqlCmd.Connection = myConnection; myConnection.Open(); int rowInserted = sqlCmd.ExecuteNonQuery(); myConnection.Close(); }
public WebAppData Get() { SqlDataReader reader = null; SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = @"Server=localhost\SQLEXPRESS01;Database=master;Trusted_Connection=True;"; SqlCommand sqlCmd = new SqlCommand(); sqlCmd.CommandType = CommandType.Text; sqlCmd.CommandText = "Select * from webAppData"; sqlCmd.Connection = myConnection; myConnection.Open(); reader = sqlCmd.ExecuteReader(); WebAppData dat = null; while (reader.Read()) { dat = new WebAppData(); dat.Guid = Convert.ToInt32(reader.GetValue(0)); dat.UserData = reader.GetString(0); } return(dat); }