Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C# SQLÊý¾Ý¿â²Ù×÷ͨÓÃÀà


C# SQLÊý¾Ý¿â²Ù×÷ͨÓÃÀà
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
namespace Framework.DataBase
{
///
/// ͨÓÃÊý¾Ý¿âÀà
///
public class DataBase
{
private string ConnStr = null;
public DataBase()
{
   ConnStr = ConfigurationSettings.AppSettings["ConnStr"];
}
public DataBase(string Str)
{
   try
   {
    this.ConnStr = Str;
   }
   catch(Exception ex)
   {
    throw ex;
   }
}
///
/// ·µ»Øconnection¶ÔÏó
///
///
public SqlConnection ReturnConn()
{
   SqlConnection Conn = new SqlConnection(ConnStr);
   Conn.Open();
   return Conn;
}
public void Dispose(SqlConnection Conn)
{
   if(Conn!=null)
   {
    Conn.Close();
    Conn.Dispose();
   }
}
///
/// ÔËÐÐSQLÓï¾ä
///
///
public void RunProc(string SQL)
{
   SqlConnection Conn;
   Conn = new SqlConnection(ConnStr);
   Conn.Open();
   SqlCommand Cmd ;
   Cmd = CreateCmd(SQL, Conn);
   try
   {
    Cmd.ExecuteNonQuery();
   }
   catch
   {
    throw new Exception(SQL);
   }
   Dispose(Conn);
   return;
}   
///
   /// ÔËÐÐSQLÓï¾ä·µ»ØDataReader
///
    ///
    /// SqlDataReader¶ÔÏó.
public SqlDataReader RunProcGetReader(string SQL)
{
   SqlConnection Conn;
   Conn = new SqlConnection(ConnStr);
   Conn.Open();
   SqlCommand Cmd ;
   Cmd = CreateCmd(SQL, Conn);
   SqlDataReader Dr;
   try
   {
    Dr = Cmd.ExecuteReader(CommandBehavior.Default);
   }
catch


Ïà¹ØÎĵµ£º

SQL¶Ô³ÌÐòÐÔÄܵÄÓ°Ïì


¡¾ÏÈ˼¿¼Ò»¸öÎÊÌ⣺Áû×ÓºÍϹ×ÓÔÚÒ»Æð»áÓÐʲô½á¹û£¿¡¿
×òÌìд³ÌÐò£¬ÓиöСģ¿éÊÇͨ¹ý·ÖÎöÊýÊ®ÍòÌõ¼Ç¼£¬ÓëÒì¹¹µÄÊý¾Ý±í½øÐбȶԣ¬ÕÒ³ö·ûºÏÌõ¼þµÄÐÅÏ¢¡£
ÔÚµÚÒ»Ìõ²éѯÖУ¬ÐèÒª²éѯËùÓмǼµÄÒ»¸ö×ֶΣ¬²¢ÌáÈ¡¸Ã×Ö¶ÎÖеĵÚ5ÖÁµÚ10¸ö×Ö·û´®£¬ÒªÓëÒì¹¹Êý¾Ý±í±È½ÏµÄ¾ÍÊÇÕâ¸ö×Ö´®¡£ÔÚ×î³õµÄ°æ±¾ÖУ¬¶ÔÓÚÐÔÄܲ¢Ã»ÓÐ×ö¸ü¶àµÄ¿¼Â ......

ÓÃË÷ÒýÌá¸ßSQL ServerÐÔÄÜ

 ÔÚ΢ÈíµÄSQL ServerϵͳÖÐͨ¹ýÓÐЧµÄʹÓÃË÷Òý¿ÉÒÔÌá¸ßÊý¾Ý¿âµÄ²éѯÐÔÄÜ£¬µ«ÊÇÐÔÄܵÄÌá¸ßÈ¡¾öÓÚÊý¾Ý¿âµÄʵÏÖ¡£ÔÚ±¾ÎÄÖн«»á¸æËßÄãÈçºÎʵÏÖË÷Òý²¢ÓÐЧµÄÌá¸ßÊý¾Ý¿âµÄÐÔÄÜ¡£¡¡
¡¡¡¡
¡¡¡¡ÔÚ¹ØϵÐÍÊý¾Ý¿âÖÐʹÓÃË÷ÒýÄܹ»Ìá¸ßÊý¾Ý¿âÐÔÄÜ£¬ÕâÒ»µãÊǷdz£Ã÷ÏԵġ£ÓõÄË÷ÒýÔ½¶à£¬´ÓÊý¾Ý¿âϵͳÖеõ½Êý¾ÝµÄËٶȾÍÔ½¿ì¡£È»¶ø£¬Ðè ......

sql update Ó÷¨

½«b±íÖÐcallerÁеÄÖµ²åÈëa±íÖÐcallÁÐÖС£
 create table a
(
 fid int,
 call varchar(20),
 age int
)
create table b
(
 fid int,
 caller varchar(20),
 parentId int
)
select * from a
select * from b
insert into a values(1,null,19)
insert into a values(2,n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ