C#´ò°üSQLÊý¾Ý¿â²¿Êð°²×°
²Î¿¼¡¶ASP.NETÓëSQLÒ»Æð´ò°ü²¿Êð°²×°¡·£¬ÕâƪÎÄÕÂÊÇÕë¶ÔVB.NETÓëSQL Ò»Æð´ò°üµÄ,µ«ÊÇÎÒʹÓõÄÊÇC#,µ±È»Ö»ÒªÐÞ¸ÄÒ»ÏÂÖ÷Òª°²×°Àà¿â¾ÍÐÐÁË!C#µÄÀà¿â´úÂëÈçÏÂ:DBCustomAction.cs
using System;
using System.Collections;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;
using System.IO;
using System.Xml;
using System.Reflection;
namespace PMS
{
/// <summary>
/// DBCustomAction µÄժҪ˵Ã÷¡£
/// </summary>
[RunInstaller(true)]
public class DBCustomAction : System.Configuration.Install.Installer
{
/// <summary>
/// ±ØÐèµÄÉè¼ÆÆ÷±äÁ¿¡£
/// </summary>
private System.ComponentModel.Container components = null;
public DBCustomAction()
{
// ¸Ãµ÷ÓÃÊÇÉè¼ÆÆ÷Ëù±ØÐèµÄ¡£
InitializeComponent();
// TODO: ÔÚ InitializeComponent µ÷ÓúóÌí¼ÓÈκγõʼ»¯
}
private void ExecuteSql(string conn,string DatabaseName,string Sql)
{
SqlConnection mySqlConnection=new SqlConnection(conn);
SqlCommand Command=new SqlCommand(Sql, mySqlConnection);
mySqlConnection.Open();
mySqlConnection.ChangeDatabase(DatabaseName);
try
{
Command.ExecuteNonQuery();
}
finally
{
//close Connection
mySqlConnection.Close();
}
}
/// <summary>
/// ÇåÀíËùÓÐÕýÔÚʹÓõÄ×ÊÔ´¡£
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
&nb
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
ÔÚÐèÒª²âÊÔsqlÓï¾ä»òÕß´æ´¢¹ý³ÌÐÔÄܵÄʱºò¿ÉÒÔÓõÃÉÏ
CHECKPOINT --ÓÃÓÚ¼ì²éµ±Ç°¹¤×÷µÄÊý¾Ý¿âÖб»¸ü¸Ä¹ýµÄÊý¾ÝÒ³»òÈÕÖ¾Ò³£¬²¢½«ÕâЩÊý¾Ý´ÓÊý¾Ý»º³åÆ÷ÖÐÇ¿ÖÆдÈëÓ²ÅÌ
GO
DBCC FreeProcCache --´Ó»º³å³ØÖÐɾ³ýËùÓлº³åÇø
DBCC DropCleanBuffers&nbs ......
1.ÏÈÆôÓà xp_cmdshell À©Õ¹´æ´¢¹ý³Ì£º
Use Master
GO
Exec sp_configure 'show advanced options', 1
GO
Reconfigure;
GO
sp_configure 'xp_cmdshell', 1
GO
Reconfigure;
GO
(×¢£ºÒòΪxp_cmdshellÊǸ߼¶Ñ¡ÏËùÒÔÕâÀïÆô¶¯xp_cmdshell£¬ÐèÒªÏȽ« show advanced ......
Ò».MYSQLµÄÃüÁîÐÐģʽµÄÉèÖãº
×ÀÃæ->ÎҵĵçÄÔ->ÊôÐÔ->»·¾³±äÁ¿->н¨->
PATH=“£»path\mysql\bin;”ÆäÖÐpathΪMYSQLµÄ°²×°Â·¾¶¡£
¶þ.¼òµ¥µÄ½éÉÜÒ»ÏÂÃüÁîÐнøÈëMYSQLµÄ·½·¨£º
1.C:\>mysql -h hostname -u username -p
°´ENTER¼ü£¬µÈ´ýÈ»ºóÊäÈëÃÜÂë¡£ÕâÀïhostnameΪ·þÎñÆ÷µÄÃû³Æ£¬Èçlocalh ......
ÒªÔÚSQL ServerÊý¾Ý¿âÖд洢m³²¢´òÓ¡³öÀ´, ·½·¨ÈçÏ£º
1£©½«Êý¾Ý¿âÖÐÏàÓ¦×ֶεÄÊý¾ÝÀàÐÍÉèΪnchar»ònvarcharÀàÐÍ¡£
2£©´ÓExcelÖеõ½m³£¬¸´ÖÆÕ³Ìùµ½½ÓÊÕÊý¾ÝµÄ¿Ø¼þÖУ¨TextBox¡¢DataGridViewµÈ£©¡£±£´æ¼´¿É¡£
×¢£º1£©nchar,nvarcharÓëchar,varcharµ ......