private void ChooseFile(TextBox Textbox)
        {
            OpenFileDialog fd = new OpenFileDialog();
            fd.InitialDirectory = Textbox.Text;
            fd.ShowDialog();
            Textbox.Text = fd.FileName;
        }public static string GetDebugStringFromCommand(SqlCommand command)
{
    string dbg = "";
    if (command == null) return "Command is NULL";    dbg = command.CommandText;    try
    {
        if (command.Parameters != null)
            foreach (SqlParameter p in command.Parameters)
            {
                dbg += "\n[" + p.ParameterName + "] - [" + p.DbType + "] - [" + p.Value+"]";
            }
    }
    catch (Exception ex)
    {
        dbg += "Error in getting parameters " + ex;
    }
    return dbg;
}

解决方案 »

  1.   

    private void ChooseFile(TextBox Textbox)
            {
                OpenFileDialog fd = new OpenFileDialog();
                fd.InitialDirectory = Textbox.Text;
                fd.ShowDialog();
                Textbox.Text = fd.FileName;
            }打开文件对话框的  把文件的地址给Textbox
    GetDebugStringFromCommand --获取到SQL参数的名,类型,以及值  并返回
      

  2.   

    1. 打开文件。2. 获得SQL命令的字符串表示。
      

  3.   


    ///文件选择
    private void ChooseFile(TextBox Textbox)
            {
                OpenFileDialog fd = new OpenFileDialog();
                fd.InitialDirectory = Textbox.Text;//路径=textbox的值
                fd.ShowDialog();//显示文件选择框
                Textbox.Text = fd.FileName;//将文件名赋值给textbox
            }
      

  4.   

    private void ChooseFile(TextBox Textbox)
            {
                OpenFileDialog fd = new OpenFileDialog();
                fd.InitialDirectory = Textbox.Text;
                fd.ShowDialog();
                Textbox.Text = fd.FileName;
            }打开文件对话框  关闭后把选择的文件显示到 TextBox控件上
    public static string GetDebugStringFromCommand(SqlCommand command)
    {
        string dbg = "";
        if (command == null) return "Command is NULL";    dbg = command.CommandText;    try
        {
            if (command.Parameters != null)
                foreach (SqlParameter p in command.Parameters)
                {
                    dbg += "\n[" + p.ParameterName + "] - [" + p.DbType + "] - [" + p.Value+"]";
                }
        }
        catch (Exception ex)
        {
            dbg += "Error in getting parameters " + ex;
        }
        return dbg;
    }这个方法 是根据SQL参数生成SQL语句... 后面是  Sql语句 [参数名]-[类型]-[数据]  不知道什么用..日志?
      

  5.   

     打开文件  获得SQL命令
      

  6.   


    //文件选择,并获取路径
    private void ChooseFile(TextBox Textbox) 

        OpenFileDialog fd = new OpenFileDialog(); //新建一个选择文件的控件
        fd.InitialDirectory = Textbox.Text; //选择文件时的初始路径设置为Textbox中的路径值
        fd.ShowDialog(); //显示选择文件窗口
        Textbox.Text = fd.FileName; //将所选择的文件路径写入Textbox中

    //获取SQL命令的SQL语句,或存储过程的信息
    public static string GetDebugStringFromCommand(SqlCommand command) 

        string dbg = ""; 
        if (command == null) return "Command is NULL"; //为空时的处理    //此处,当SQL命令的类型为CommandText时,获取的是SQL语句;
         //当SQL命令的类型为StoredProcedure存储过程时,获取的是存储过程的名称
        dbg = command.CommandText;     //下面是对SQL命令类型为存储过程时的继续解析
        try 
        { 
            //存储过程有Parameters
            if (command.Parameters != null) 
                //对每个参数进行处理
                foreach (SqlParameter p in command.Parameters) 
                { 
                    //每行显示一个参数信息,显示格式为[参数名]-[参数类型]-[参数值]
                    dbg += "\n[" + p.ParameterName + "] - [" + p.DbType + "] - [" + p.Value+"]"; 
                } 
        } 
        catch (Exception ex) 
        { 
            //如果某一行抛出异常,进行记录 
            dbg += "Error in getting parameters " + ex; 
        } 
        return dbg; //返回处理结果