zoukankan      html  css  js  c++  java
  • 网络游戏_数据库删除

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using MySql.Data.MySqlClient;

    namespace MySql数据库操作
    {
        class Program
        {
            static void Main(string[] args)
            {
                string connStr = "Database=game;Data Source=127.0.0.1;port=3306;User Id=root;Password=shirln123My;";
                MySqlConnection conn = new MySqlConnection(connStr);
                conn.Open();

                #region 查询
                // MySqlCommand cmd = new MySqlCommand("select * from user where id=1", conn);
                // MySqlDataReader reader = cmd.ExecuteReader();
                //while(reader.Read())
                // {              
                //     string username = reader.GetString("username");
                //     string password = reader.GetString("password");
                //     Console.WriteLine(username+";"+password);

                // }
                // reader.Close();
                #endregion

                #region 插入
                //string username = "cwer";
                //string password = "qwedv';delete  from user;";
                ////MySqlCommand cmd = new MySqlCommand("insert into user set username='" + username + "'" + ",password='" + password + "'", conn);
                ////cmd.ExecuteNonQuery();
                //MySqlCommand cmd = new MySqlCommand("insert into user set username=@un,password=@pwd", conn);
                //cmd.Parameters.AddWithValue("un", username);
                //cmd.Parameters.AddWithValue("pwd", password);
                //cmd.ExecuteNonQuery();
                #endregion

                #region 删除
                MySqlCommand cmd = new MySqlCommand("delete from user where id=@id", conn);
                cmd.Parameters.AddWithValue("id", 10);
                cmd.ExecuteNonQuery();
                #endregion

                conn.Close();
                Console.ReadKey();
            }
        }
    }                                                      

  • 相关阅读:
    设计模式入门--设计模式原则(总纲)
    Chart图形 [GDI+] OWCChart统计图的封装类 (转载)
    Chart图形 [功能帮助类] Assistant创建显示图像的标签和文件 (转载)
    [GDI+] 生成缩略图的类文件SmallImage (转载)
    [Mime] 在c#程序中放音乐的帮助类 (转载)
    [访问系统] Api_Win32_Mac类工具包 (转载)
    [访问系统] C#计算机信息类ComputerInfo (转载)
    [Jquery] jQuery.cookie帮助类 (转载)
    [综合|基础|语法] 最新的皮肤帮助类 UI_Misc_Helper (转载)
    [JS] JavascriptHelp (转载)
  • 原文地址:https://www.cnblogs.com/shirln/p/7875196.html
Copyright © 2011-2022 走看看