Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 SERVER×Ö¶ÎÀàÐÍ˵Ã÷

 
bit£º0»ò1µÄÕûÐÍÊý×Ö
int£º´Ó-2^31(-2,147,483,648)µ½2^31(2,147,483,647)µÄÕûÐÍÊý×Ö
smallint£º´Ó-2^15(-32,768)µ½2^15(32,767)µÄÕûÐÍÊý×Ö
tinyint£º´Ó0µ½255µÄÕûÐÍÊý×Ö

decimal£º´Ó-10^38µ½10^38-1µÄ¶¨¾«¶ÈÓëÓÐЧλÊýµÄÊý×Ö
numeric£ºdecimalµÄͬÒå´Ê

money£º´Ó-2^63(-922,337,203,685,477.580 ......

SQLÓï¾ä

1. ˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ£¬Ô´±íÃû£ºa£¬Ð±íÃû£ºb)
SQL: select * into b from a where 1<>1;
        2. ˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý£¬Ô´±íÃû£ºa£¬Ä¿±ê±íÃû£ºb)
SQL: insert into b(a, b, c) select d, e, f from b;
        3. ˵Ã÷£º ......

sql ²éѯÖظ´¼Ç¼2


========µÚһƪ=========
ÔÚÒ»ÕűíÖÐij¸ö×Ö¶ÎÏÂÃæÓÐÖظ´¼Ç¼£¬Óкܶ෽·¨£¬µ«ÊÇÓÐÒ»¸ö·½·¨£¬ÊDZȽϸßЧµÄ£¬ÈçÏÂÓï¾ä£º
select data_guid from adam_entity_datas a where a.rowid > (select min(b.rowid) from adam_entity_datas b where b.data_guid = a.data_guid)
Èç¹û±íÖÐÓдóÁ¿Êý¾Ý£¬µ«ÊÇÖظ´Êý¾Ý±È½ÏÉÙ£¬ÄÇô ......

SQL SERVER

sql server·Ö²¼Ê½ÊÂÎñ½â¾ö·½°¸
ÊÊÓû·¾³
²Ù×÷ϵͳ£ºwindows 2003
Êý¾Ý¿â£ºsql server 2000/sql server 2005
ʹÓÃÁ´½Ó·þÎñÆ÷½øÐÐÔ¶³ÌÊý¾Ý¿â·ÃÎʵÄÇé¿ö
Ò»¡¢  ÎÊÌâÏÖÏó
ÔÚÖ´Ðзֲ¼Ê½ÊÂÎñʱ£¬ÔÚsql server 2005ÏÂÊÕµ½ÈçÏ´íÎó£º
ÏûÏ¢ 7391£¬¼¶±ð 16£¬×´Ì¬ 2£¬¹ý³Ì xxxxx£¬µÚ 16 ÐÐ
ÎÞ·¨Ö´ÐиòÙ×÷£¬ÒòΪÁ´½Ó·þÎñ ......

oracleÖÐʵÏֵݹé²éѯµÄSQL£¨connect by prior£©

    Ç°¶Îʱ¼ä×öÁËÒ»¸öÐéÄâ×éÖ¯µÄ´´½¨¡£Õâ¸öÐéÄâ×éÖ¯µÄ´´½¨ÊÇ´ÓÏÖÓеÄ×éÖ¯ÖжÁÈ¡Êý¾ÝÈ»ºó½øÐзÖÎö±£´æµ½ÐéÄâ×éÖ¯±íÖС£±£´æÖ®ºóдÈÕÖ¾·½±ãͬ²½µ½ÆäËüϵͳÖС£¹«Ë¾Ê¹ÓõÄÖ÷Òª¼¼ÊõÊÇSSH¡£ÓÉÓÚÊÇÐÂÈËûÓÐʲô¾­Ñ飬¼Ó֮ʱ¼ä±È½Ï½ôÆÈ£¬×îºóʹÓÃÒ»°ãµÄÂß¼­Ë¼Ïëͨ¹ýµÝ¹éÔÚhibernateÏÂ˳Àû´´½¨ÁË¡£¿ÉÊÇ´ÓÏÖÓеÄ×éÖ¯Ö ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ