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

SQL Server µÄÁ¬½Ó¡¢²éѯÓë¸üÐÂ

#Region " ÃüÃû¿Õ¼ä "
Imports System.Data
Imports System.Data.SqlClient
#End Region
Public Class DBCommon
Implements IDisposable
#Region " ³ÉÔ±±äÁ¿ "
Private conn As SqlConnection
Private cmd As SqlCommand
Private trans As SqlTransaction
#End Region
#Region " ¹¹Ô캯Êý "
Public Sub New()
Connection()
End Sub
#End Region
#Region " ¹ý³Ìº¯Êý "
Public Sub Dispose() Implements IDisposable.Dispose
Close()
End Sub
Public Sub Close()
If conn Is Nothing Then
Return
End If
conn.Close()
conn.Dispose()
conn = Nothing
End Sub
Public Sub ClearParameter()
cmd.Parameters.Clear()
End Sub
Public Sub AddParameter( _
ByVal ParameterName As String, _
ByVal SqlDbType As SqlDbType, _
ByVal Size As Integer, _
ByVal Value As Object)
cmd.Parameters.Add(ParameterName, SqlDbType, Size).Value = Value
End Sub
Public Sub Fill( _
ByVal dtResult As DataTable, _
ByVal strSqlBun As String, _
ByVal Parameter As SqlParameter)
Dim objAdpt As SqlDataAdapter
objAdpt = New SqlDataAdapter(strSqlBun, conn)
cmd.CommandText = strSqlBun
objAdpt.SelectCommand = cmd
objAdpt.Fill(dtResult)
End Sub
Public Sub ExecuteNonQuery(ByVal strSqlBun As String)
cmd.CommandText = strSqlBun
cmd.ExecuteNonQuery()
End Sub
Public Sub BeginTransaction()
trans = conn.BeginTransaction()
End Sub
Public Sub Commit()
trans.Commit()
End Sub
Public Sub Rollback()
trans.Rollback()
End Sub
Protected Overrides Sub Finalize()
Close()
MyBase.Finalize()
End Sub
Private Sub Connection()
Dim strConnectionString As String
strConnectionString = My.MySettings.Default.ConnectionString
conn = New SqlConnection(strConnectionS


Ïà¹ØÎĵµ£º

SQLÖÐÈçºÎÓÃÒ»¸ö±í¸üÐÂÁíÒ»¸ö±í

for ACCESS :
update a, b set a.name=b.name1 where a.id=b.id
for SQL Server:
"update a set a.name=b.name1 from a,b where a.id=b.id"
update   a   set   a.status=b.status  
  from   table1   a,table2   b  
&nbs ......

¹ØÓÚÍøÕ¾SQL×¢ÈëµÄÎÊÌâ,ÒÔ¼°½â¾ö°ì·¨


×î½ü·¢ÏÖÎÒÃǹ«Ë¾µÄASP.NETµÄ´úÂëÓÐÆ´½ÓSQLÓï¾äµÄÏ°¹ß£¡ÕâÊǷdz£Î£Ïյġ£ÒÔÏÂÎÒ¾ÙÀý˵Ã÷Ò»ÏÂ
Àý×Ó1£º
statement := "SELECT * from users WHERE name = '" + userName + "'; "
½«Óû§Ãû±äÁ¿(¼´username)ÉèÖÃΪ£º
a' or 't'='t£¬´ËʱԭʼÓï¾ä·¢ÉúÁ˱仯£º
SELECT * from users WHERE name = 'a' OR 't'='t';
Èç¹ûÕâ ......

SQL Mirror HA(SQL serverµÄ¸ß¿ÉÓÃÐÔ)[תÔØ]


¶ÔSQL Server 2008 ½øÐÐMirrorµÄ»ù±¾ÅäÖü°°²×°¡£
×¼±¸¹¤×÷
1. Principal ÓëMirror ÒÔ¼° Witness Èý̨ʵÀý¶¼°²×°ÎªÏàͬ°æ±¾£¬Ä¿Ç°Êǵ½SQL Server 2008 SP1¡£
2. ÐèÒªÓÐÒ»¸öÓòÕÊ»§·Ö±ðÌí¼Óµ½ Èý̨Êý¾Ý¿âʵÀýËùÔÚµÄServer µÄ Administrators×é¡¢ÒÔ¼°SQL Server Ïà¹ØµÄ×éÖУ» ÓÉÓÚ¾ßÌåµÄ×éµÄ¹¦Äܲ»Çå³þ£¬Òò´Ë½¨ÒéËùÓ ......

ÔÚSQL Server 2005ÖÐÓô洢¹ý³ÌʵÏÖËÑË÷¹¦ÄÜ


ÏÖÔںܶàÍøÕ¾¶¼ÌṩÁËÕ¾ÄÚµÄËÑË÷¹¦ÄÜ£¬Óеĺܼòµ¥ÔÚSQLÓï¾äÀï¼ÓÒ»¸öÌõ¼þÈ磺where names like ‘%words%’¾Í¿ÉÒÔʵÏÖ×î»ù±¾µÄËÑË÷ÁË¡£
    ÎÒÃÇÀ´¿´¿´¹¦ÄÜÇ¿´óÒ»µã£¬¸´ÔÓÒ»µãµÄËÑË÷ÊÇÈçºÎʵÏֵģ¨ÔÚSQL¡¡£Ó£Å£Ò£Ö£Å£Ò£²£°£°£¯£²£°£°£µÍ¨¹ý´æ´¢¹ý³ÌʵÏÖËÑË÷Ëã·¨£©¡£
    ÎÒÃÇ ......

ÍƼö̽ÌÖÕä²Ø¡¾¾­µäSQLÓï¾ä´óÈ«¡¿

ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ