当前位置 : 主页 > 编程语言 > c语言 >

(常用)C# 连接数据库进行增删查改的基本模板

来源:互联网 收集:自由互联 发布时间:2021-06-25
string conn_str = @" Server=(local); database = YJ_Database; User id = sa; Password = 123456 " ; SqlConnection conn = new SqlConnection(conn_str); conn.Open(); string sql = " insert into t_Organization values(‘ " +_FNumber+ " ‘,‘ " +_
string conn_str = @"Server=(local); database = YJ_Database; User id = sa; Password = 123456";
            SqlConnection conn = new SqlConnection(conn_str);
            conn.Open();
            string sql = "insert into t_Organization values(‘"+_FNumber+"‘,‘"+_FName+"‘)";
            SqlCommand cmd = new SqlCommand(sql, conn);
            int n=cmd.ExecuteNonQuery();
            conn.Close();
网友评论