当前位置: 首页>>代码示例>>C#>>正文


C# SqlClient.SqlDataAdapter类代码示例

本文整理汇总了C#中System.Data.SqlClient.SqlDataAdapter的典型用法代码示例。如果您正苦于以下问题:C# SqlDataAdapter类的具体用法?C# SqlDataAdapter怎么用?C# SqlDataAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SqlDataAdapter类属于System.Data.SqlClient命名空间,在下文中一共展示了SqlDataAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetHandoverLogByHandoverLogId

        public static DataTable GetHandoverLogByHandoverLogId(int handoverLogId)
        {
            string connectionString = ConnectionStringFactory.GetNXJCConnectionString();
            DataSet ds = new DataSet();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = connection.CreateCommand();
                command.CommandText = @"SELECT  WorkingTeamShiftLog.*,
                                                StaffInfo.Name AS ChargeManName, ProductLine.Name AS ProductLineName,
                                                WorkingTeam.Name AS WorkingTeamName
                                        FROM    WorkingTeam INNER JOIN
                                                StaffInfo INNER JOIN
                                                WorkingTeamShiftLog ON StaffInfo.ID = WorkingTeamShiftLog.ChargeManID INNER JOIN
                                                ProductLine ON WorkingTeamShiftLog.ProductLineID = ProductLine.ID ON
                                                WorkingTeam.ID = WorkingTeamShiftLog.WorkingTeamID
                                        WHERE   (WorkingTeamShiftLog.ID = @workingTeamShiftLogID)";

                command.Parameters.Add(new SqlParameter("workingTeamShiftLogID", handoverLogId));
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                adapter.Fill(ds);
            }

            return ds.Tables[0];
        }
开发者ID:nxjcproject,项目名称:nxjcslim,代码行数:25,代码来源:HandoverLogService.cs

示例2: LerUsuarios_Desconectado

        public static void LerUsuarios_Desconectado()
        {
            DataSet ds = new DataSet();

            using (var con = ObterConexao())
            {
                var cmd = con.CreateCommand();

                cmd.CommandText = "SELECT * FROM Usuario";

                SqlDataAdapter da = new SqlDataAdapter(cmd);

                da.Fill(ds);
            }

            foreach (DataTable table in ds.Tables)
            {
                foreach (DataColumn column in table.Columns)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        Console.WriteLine("{0}: {1}", column.ColumnName, row[column.ColumnName]);
                    }
                }
            }

            Console.Read();
        }
开发者ID:TiagoSoczek,项目名称:MOC,代码行数:28,代码来源:Program.cs

示例3: GetInvoiceNoCorrespondingtoLedgerForPurchaseReturnReport

 /// <summary>
 /// Get InvoiceNo Corresponding to Ledger For PurchaseReturn Register
 /// </summary>
 /// <param name="decLedgerId"></param>
 /// <returns></returns>
 public List<DataTable> GetInvoiceNoCorrespondingtoLedgerForPurchaseReturnReport(decimal decLedgerId, decimal decVoucherId)
 {
     List<DataTable> ListObj = new List<DataTable>();
     DataTable dtbl = new DataTable();
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlDataAdapter sqldataadapter = new SqlDataAdapter("GetInvoiceNoCorrespondingtoLedgerForPurchaseReturnReport", sqlcon);
         sqldataadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
         SqlParameter sqlparameter = new SqlParameter();
         sqlparameter = sqldataadapter.SelectCommand.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sqlparameter.Value = decLedgerId;
         sqlparameter = sqldataadapter.SelectCommand.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sqlparameter.Value = decVoucherId;
         sqldataadapter.Fill(dtbl);
         ListObj.Add(dtbl);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     finally
     {
         sqlcon.Close();
     }
     return ListObj;
 }
开发者ID:JaseelAM,项目名称:OpenMiracle-Three-Tier,代码行数:35,代码来源:PurchaseReturnMasterSP.cs

示例4: dataGridView1_CellContentClick

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            SqlConnection con = new SqlConnection(constring);
            con.Open();

            int curRow = int.Parse(e.RowIndex.ToString());
            string currentrow;
            currentrow = dataGridView1.Rows[curRow].Cells[1].Value.ToString();

            SqlDataAdapter adp1 = new SqlDataAdapter("Select * from ResManagerToAdmin where ResID='" + currentrow + "'", con);
            DataSet ds1 = new DataSet();
            adp1.Fill(ds1);

            SqlCommand cmd = new SqlCommand("Update ResManagerToAdmin set RView='" + p2 + "' where ResID='" + currentrow + "'", con);
            cmd.ExecuteNonQuery();

            SqlCommand cmd1 = new SqlCommand("Update ResManagerToAdmin set RFinalView='" + p2 + "' where ResID='" + currentrow + "'", con);
            cmd1.ExecuteNonQuery();

            status = ds1.Tables[0].Rows[0]["RStatus"].ToString();

            if (status == "Success")
            {
                ViewAdminResponses var = new ViewAdminResponses();
                var.ShowDialog();
            }
            else
            {
                RecordNotFound rnf = new RecordNotFound();
                rnf.ShowDialog();
            }
        }
开发者ID:balajivit1,项目名称:Sourcecode,代码行数:32,代码来源:User.cs

示例5: button1_Click_1

        private void button1_Click_1(object sender, EventArgs e)
        {
            SqlConnection con1 = new SqlConnection(constring);
            con1.Open();
            SqlDataAdapter adp = new SqlDataAdapter("Select whoislogin from Registration", con1);
            DataSet ds = new DataSet();
            adp.Fill(ds);
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                SqlCommand cmd = new SqlCommand("Update Registration set whoislogin='" + whoislog + "'", con1);
                cmd.ExecuteNonQuery();
            }

            SqlDataAdapter adp2 = new SqlDataAdapter("Select * from ResManagerToAdmin", con1);
            DataSet ds2 = new DataSet();
            adp2.Fill(ds2);
            for (int j = 0; j < ds2.Tables[0].Rows.Count; j++)
            {
                //adminview = ds.Tables[0].Rows[j]["RView"].ToString();
                SqlCommand cmd = new SqlCommand("Update ResManagerToAdmin set RView='" + adminviewempty + "'", con1);
                cmd.ExecuteNonQuery();
            }

            con1.Close();
            this.Close();
        }
开发者ID:balajivit1,项目名称:Sourcecode,代码行数:26,代码来源:User.cs

示例6: ExecuteParamerizedSelectCommand

        // This function will be used to execute R(CRUD) operation of parameterized commands
        internal static DataTable ExecuteParamerizedSelectCommand(string CommandName, CommandType cmdType, SqlParameter[] param)
        {
            DataTable table = new DataTable();

            using (SqlConnection con = new SqlConnection(CONNECTION_STRING))
            {
                using (SqlCommand cmd = con.CreateCommand())
                {
                    cmd.CommandType = cmdType;
                    cmd.CommandText = CommandName;
                    cmd.Parameters.AddRange(param);

                    try
                    {
                        if (con.State != ConnectionState.Open)
                        {
                            con.Open();
                        }

                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(table);
                        }
                    }
                    catch
                    {
                        throw;
                    }
                }
            }

            return table;
        }
开发者ID:kma14,项目名称:AC,代码行数:34,代码来源:SqlDBHelper.cs

示例7: ExecuteDataSet

        public static DataSet ExecuteDataSet(CommandType cmdType, string strProcedureName, SqlParameter[] objParameters)
        {
            DataSet dset = new DataSet();
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["db1ConnectionString"].ToString());
            con.Open();
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = con;
                cmd.CommandType = cmdType;
                cmd.CommandText = strProcedureName;

                AttachParameters(cmd, objParameters);

                SqlDataAdapter ad = new SqlDataAdapter(cmd);
                ad.Fill(dset);

                return dset;

            }
            catch (Exception ex)
            {
                return dset;
            }
            finally
            {
                con.Close();
            }
        }
开发者ID:hbb20,项目名称:gtu_pde,代码行数:29,代码来源:DataAccess.cs

示例8: FilterData

        public DataSet FilterData(ArsonFilterModel filterData)
        {
            var connectionString = ConfigurationManager.ConnectionStrings["UCR_DataEntities"];
            DataSet dsResult = new DataSet();
            using (SqlConnection conn = new SqlConnection(connectionString.ConnectionString))
            {
                try
                {
                    SqlCommand command = new SqlCommand();
                    command.Connection = conn;
                    command.CommandText = GenerateArsonORQuery(filterData);
                    command.CommandType = System.Data.CommandType.Text;
                    SqlDataAdapter adapter = new SqlDataAdapter();
                    adapter.SelectCommand = command;

                    conn.Open();
                    adapter.Fill(dsResult);
                    conn.Close();
                    adapter.Dispose();
                    command.Dispose();
                }
                catch (Exception ex)
                {
                    StorageClient.LogError(ex);
                }
            }
            return dsResult;
        }
开发者ID:yogsgit,项目名称:FBIUCRDashboard,代码行数:28,代码来源:DataAccess.cs

示例9: ObtenerDatos

        public DataTable ObtenerDatos(String ComandoSql)
        {
            SqlDataAdapter adapter;
            DataTable dt = new DataTable();

            try
            {
                con.Open();
                Cmd.Connection = con;
                Cmd.CommandText = ComandoSql;

                adapter = new SqlDataAdapter(Cmd);
                adapter.Fill(dt);

            }
            catch (Exception ex)
            {
                throw ex;
                //MessageBox.Show(ex.Message);
            }
            finally
            {
                con.Close();
            }

            return dt;
        }
开发者ID:elnata93,项目名称:RegistroPeliculas,代码行数:27,代码来源:ConexionDb.cs

示例10: InsertKhachHang

        public string InsertKhachHang(string TenKH, string Gioitinh, string Diachi, string SDT, string LoaiKH, string Ghichu)
        {
            string str = "";
            string sql = "InsertKH";
            //   string sql = "insert NhomSP values (@Manhom, @Tennhom, @NgayCN)";
            SqlConnection con = new SqlConnection(KetNoiDB.getconnect());
            con.Open();
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@TenKH", TenKH);
            cmd.Parameters.AddWithValue("@gt", Gioitinh);
            cmd.Parameters.AddWithValue("@DC", Diachi);
            cmd.Parameters.AddWithValue("@SDT", SDT);
            cmd.Parameters.AddWithValue("@LoaiKH", LoaiKH);
            cmd.Parameters.AddWithValue("@ghichu", Ghichu);
            //cmd.ExecuteNonQuery();

            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            str = dt.Rows[0].ItemArray[0].ToString();

            cmd.Dispose();
            con.Close();

            return str;
        }
开发者ID:BachDieuLinh,项目名称:QLSieuThi,代码行数:27,代码来源:KhachHang.cs

示例11: GetAll

 public DataSet GetAll(string empresaid, tb_co_tablasunat BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCoTablaSunat_CONSULTA", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@tablaid", SqlDbType.Char, 10).Value = BE.tablaid;
                 cmd.Parameters.Add("@codigoid", SqlDbType.Char, 4).Value = BE.codigoid;
                 cmd.Parameters.Add("@nomlike1", SqlDbType.VarChar, 500).Value = BE.nomlike1;
                 cmd.Parameters.Add("@nomlike2", SqlDbType.VarChar, 500).Value = BE.nomlike2;
                 cmd.Parameters.Add("@nomlike3", SqlDbType.VarChar, 500).Value = BE.nomlike3;
                 cmd.Parameters.Add("@norden", SqlDbType.Int).Value = BE.norden;
                 cmd.Parameters.Add("@incluir_blanco", SqlDbType.Int).Value = BE.incluir_blanco;
             }
             cnx.Open();
             try
             {
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 Sql_Error = ex.Message;
                 throw new Exception(ex.Message);
             }
         }
     }
 }
开发者ID:njmube,项目名称:ErpBapSoftNet_Producion,代码行数:35,代码来源:tb_co_tablasunatDA.cs

示例12: GetAll

 public DataSet GetAll(string empresaid, tb_co_tabla01_mediopago BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCoTabla01Mediopago_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@codigoid", SqlDbType.Char, 3).Value = BE.codigoid;
                 cmd.Parameters.Add("@descripcion", SqlDbType.VarChar, 100).Value = BE.descripcion;
                 cmd.Parameters.Add("@sigla", SqlDbType.Char, 3).Value = BE.sigla;
                 cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
开发者ID:njmube,项目名称:ErpBapSoftNet_Producion,代码行数:31,代码来源:tb_co_tabla01_mediopagoDA.cs

示例13: GetAllAutos

        public IList<Models.Auto> GetAllAutos()
        {
            DataSet ds = new DataSet();

            myCommand = new SqlDataAdapter("Select * from Auto", myConnection);

            ds = new DataSet();

            myCommand.Fill(ds);

            IList<Models.Auto> AutoList = new List<Models.Auto>();

            foreach (DataRow item in ds.Tables[0].Rows)
            {
                AutoList.Add(new Auto
                {
                    AutoNumber = item["AutoNumber"].ToString(),
                    AutoName = item["AutoName"].ToString()
                });
            }

            ds.Dispose();
            ds = null;

            return AutoList;
        }
开发者ID:dfwdino,项目名称:Closed-MVC-GasTracker,代码行数:26,代码来源:ASQLFunctions.cs

示例14: load_price

        protected void load_price()
        {
            string price_name = null;
            string article = null;
            price_name = Request.QueryString["price_name"];
            article = Request.QueryString["article"];

            if (article != null)
            {
                if (price_name != null)
                {

                    SqlConnection con = new SqlConnection(str);
                    string sql = "SELECT id, article, ROUND([price]*(SELECT course FROM Course_USD WHERE id = 1),2) AS [price] FROM " + price_name + " WHERE article=" + article + ";";
                    SqlDataAdapter da = new SqlDataAdapter(sql, con);
                    DataSet ds = new DataSet();
                    da.Fill(ds, price_name);
                    DataRow dr;
                    dr = ds.Tables[price_name].Rows[0];

                    //Заполняем стоимость товара:
                    lblprice.Text = dr["price"].ToString();
                }
                else {Response.Redirect("Error.aspx");}

            }
            else {Response.Redirect("Error.aspx"); }
        }
开发者ID:sgkMoscow,项目名称:vorsinstrument,代码行数:28,代码来源:Zubilo_po_betonu_ploskoe_40x250mm_SDS_plus_Optim.aspx.cs

示例15: getTotalCount

    protected int getTotalCount()
    {
        SqlConnection connection = new SqlConnection(GetConnectionString());

        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            string sqlStatement = "SELECT * FROM tblContact";
            SqlCommand sqlCmd = new SqlCommand(sqlStatement, connection);
            SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
            sqlDa.Fill(dt);

        }
        catch (System.Data.SqlClient.SqlException ex)
        {
            string msg = "Fetch Error:";
            msg += ex.Message;
            throw new Exception(msg);
        }
        finally
        {
            connection.Close();
        }
        return dt.Rows.Count;
    }
开发者ID:FaisalRizwan,项目名称:project,代码行数:27,代码来源:Default.aspx.cs


注:本文中的System.Data.SqlClient.SqlDataAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。