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
Ïà¹ØÎĵµ£º
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 ......
Ò»¶Îʱ¼äÀ´£¬Ã¿ÌìµÄ¹¤×÷¶¼±È½ÏÔÓ£¬vb,asp,c#,sql£¬Ã¿Ï×÷¶¼Òª¸ã£¬ÊµÔÚÊÇÀÛ£¡¹¤×÷Ö®Ó࣬ÏëÏ빫˾ºÍ¹¤×÷µÄÇé¿ö£¬¿´À´ÊÇÓбØÒª»»¸ö»·¾³ÁË¡£²»¹ýÒ²ÒªÏÈ°ÑÄ¿Ç°µÄ¹¤×÷´¦ÀíÍê³É°¡¡£
×î½üÓÖÓöµ½Ò»¸öÎÊÌ⣺һ¼Ò¿Í»§Ê¹ÓÃÖеÄÊý¾Ý¿â£¬ÈÕÖ¾ÎļþÒì³£Ôö´ó£¬Æ½¾ùÿÌìÔö¼Ó´óÔ¼Ò»¸öG£¬¶øÊý¾ÝÎļþ±ä» ......
»ñÈ¡¡¢Ôö¼Ó¡¢Ð޸ġ¢É¾³ýsqlserver×Ö¶ÎÃèÊö
Select o.name AS tableName, c.name AS columnName, p.[value] AS Description
from sysproperties p INNER JOIN
sysobjects o ON o.id = p.id INNER JOIN
syscolumn ......
ORACLEºÍSQLÓï·¨Çø±ð¹éÄÉ
Êý¾ÝÀàÐͱȽÏ
ÀàÐÍÃû³Æ
Oracle
SQLServer
±È½Ï
×Ö·ûÊý¾ÝÀàÐÍ CHAR CHAR ¶¼Êǹ̶¨³¤¶È×Ö·û×ÊÁϵ«oracleÀïÃæ×î´ó¶ÈΪ2kb£¬SQLServerÀïÃæ×î´ó³¤¶ÈΪ8kb
±ä³¤×Ö·ûÊý¾ÝÀàÐÍ VARCHAR2 VARCHAR OracleÀïÃæ×î´ó³¤¶ÈΪ4kb£¬SQLServerÀïÃæ×î´ó³¤¶ÈΪ8kb
¸ù¾Ý×Ö·û¼¯¶ø¶¨µÄ¹Ì¶¨³¤¶È×Ö·û´® NCHAR NCHA ......