コード例 #1
0
        private static void UpdateProcedure(string connect)
        {
            int    id      = MyConsole.GetNumber("Enter the Id:");
            string name    = MyConsole.GetString("Enter the Name: ");
            string address = MyConsole.GetString("Enter the Address:");

            SqlConnection dbConnection = new SqlConnection(connect);
            SqlCommand    command      = new SqlCommand("EmpUpdate", dbConnection);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@param1", id);
            command.Parameters.AddWithValue("@param2", name);
            command.Parameters.AddWithValue("@param3", address);

            try
            {
                //open Connection

                dbConnection.Open();

                command.ExecuteNonQuery();
            }
            catch (SqlException)
            {
                Console.WriteLine("Someting went wrong");
            }
            finally
            {
                dbConnection.Close();
            }
        }
コード例 #2
0
ファイル: CompleteExample.cs プロジェクト: sureshk5/.Net
            private static void addTravelDetails()
            {
                if (blog.CurrentUser == null)
                {
                    Console.WriteLine("U have not logged in to Post a Travel Info");
                    Console.WriteLine("Please login to add new details");
                    return;
                }
                Travel details = new Travel();

                details.NoOfDays        = MyConsole.GetNumber("Enter the No of days of Travel");
                details.ModeOfTransport = MyConsole.GetMode();
                details.DateOfTravel    = MyConsole.GetDate("Enter the date as dd/MM/yyyy");
                details.Destination     = MyConsole.GetString("Enter UR place of Visit");
                details.UserDetails     = blog.CurrentUser;
                details.Details         = MyConsole.GetString("Please enter UR Experience in the Travel to be shared to all our visitors");
                try
                {
                    blog.AddTravelDetails(details);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
コード例 #3
0
ファイル: AdoCRUD.cs プロジェクト: DarkCode7dev/AdoConnection
        private static void UpdateRecords(string connect, string updateQuery)
        {
            int    id      = MyConsole.GetNumber("Enter the Id:");
            string name    = MyConsole.GetString("Enter the Name: ");
            string address = MyConsole.GetString("Enter the Address:");

            SqlConnection dbConnection = new SqlConnection(connect);
            SqlCommand    command      = new SqlCommand(updateQuery, dbConnection);

            command.Parameters.AddWithValue("@id", id);
            command.Parameters.AddWithValue("@Name", name);
            command.Parameters.AddWithValue("@Address", address);

            try
            {
                //open Connection

                dbConnection.Open();

                command.ExecuteNonQuery();
            }
            catch (SqlException)
            {
                Console.WriteLine("Someting went wrong");
            }
            finally
            {
                dbConnection.Close();
            }
        }
コード例 #4
0
ファイル: AdoCRUD.cs プロジェクト: DarkCode7dev/AdoConnection
        private static void DeleteRecords(string connect, string deletequery)
        {
            int id = MyConsole.GetNumber("Enter the Id:");


            SqlConnection dbConnection = new SqlConnection(connect);
            SqlCommand    command      = new SqlCommand(deletequery, dbConnection);

            command.Parameters.AddWithValue("@id", id);


            try
            {
                //open Connection

                dbConnection.Open();

                command.ExecuteNonQuery();
            }
            catch (SqlException)
            {
                Console.WriteLine("Someting went wrong");
            }
            finally
            {
                dbConnection.Close();
            }
        }
コード例 #5
0
ファイル: travelLog.cs プロジェクト: Mebanteidor/DotNet
            private static void registerUser()
            {
                int    userId   = MyConsole.GetNumber("Enter user id: ");
                string username = MyConsole.GetString("Enter username:"******"Enter password: ");

                userCredentials.RegisterNewUser(new User {
                    UserID = userId, UserName = username, Password = password
                });
                //throw new NotImplementedException();
            }
コード例 #6
0
ファイル: CompleteExample.cs プロジェクト: sureshk5/.Net
            private static void signUpFeature()
            {
                int    userID   = MyConsole.GetNumber("Enter the UserID");
                string username = MyConsole.GetString("Enter the Username");
                string password = MyConsole.GetString("Enter the password");
                string retype   = MyConsole.GetString("Retype the pasword");

                if (password != retype)
                {
                    Console.WriteLine("Password mismatch");
                    return;
                }
                try
                {
                    IUserLog log = new UserLog();
                    log.RegisterNewUser(new User {
                        UserID = userID, UserName = username, Password = password
                    });
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }