我如何在C#中调用DDL脚本语言,创建数据库或表,或备份数据库的命令?

解决方案 »

  1.   

    和执行其他Sql语句一样,把命令放在字符串中,建一个SqlCommand,然后用ExecuteNonQuery来执行
      

  2.   

    添加引用该dll 其中的类你就可以用了 不知道是不是这个意思
      

  3.   

    DDL-Data Difinition Language,数据定义语言的缩写, not dll
      

  4.   

    using System;using System.Data;using System.Collections;using System.Xml;using System.IO;using System.Text;using System.Diagnostics; namespace Zhzuo{         public class ZZConsole         {                   [STAThread]                   static void Main(string[] args)                   {                            string sqlQuery = "osql.exe /uSa /p123 /s192.192.132.229 /dNorthWind /i yoursql.sql";                            string strRst = ExeCommand(sqlQuery);                            Console.WriteLine(strRst);                            Console.ReadLine();                   }                                     public static string ExeCommand(string commandText)                   {                            Process p = new Process();                            p.StartInfo.FileName = "cmd.exe";                            p.StartInfo.UseShellExecute = false;                            p.StartInfo.RedirectStandardInput = true;                            p.StartInfo.RedirectStandardOutput = true;                            p.StartInfo.RedirectStandardError = true;                            p.StartInfo.CreateNoWindow = true;                            string strOutput = null;                            try                            {                                     p.Start();                                     p.StandardInput.WriteLine(commandText);                                     p.StandardInput.WriteLine("exit");                                     strOutput = p.StandardOutput.ReadToEnd();                                     p.WaitForExit();                                     p.Close();                            }                            catch(Exception e)                            {                                     strOutput = e.Message;                            }                            return strOutput;                   }         }}更多,
    http://blog.csdn.net/zhzuo/archive/2004/12/25/229006.aspx
      

  5.   

    添加相关的引用就可以了。如果调用数据库表的话,直接写Sql语句就可。