我要实现读一个脚本文件如:
---------------------------------------------------------------------------------------------------------
                             ---(部门表)---
---------------------------------------------------------------------------------------------------------CREATE TABLE smDept (
       cDeptNo              char(6) NOT NULL,     ----部门编号
       vcDeptName           varchar(50) NULL,     ----部门名称
       cParenttNo           char(6) NULL,         ----上级部门编号
       vcDesc               char(200) NULL,       ----部门描述
       bLastLevel           bit NULL DEFAULT 0,   ----是否末级1:是,0:否 默认:0
       bActive              bit NULL DEFAULT 1,   ----是否有效1:有效,默认 0:无效
       PRIMARY KEY (cDeptNo ASC)
)
go
Insert Into smDept(cDeptNo,vcDeptName,cParenttNo,vcDesc,bLastLevel) values('admin','系统管理','jxtcmi','具有系统最高权限','1')
我想在.NET+C#实现读取上一段脚本用下面这段代码实现private void strReadSQL(string  strFile,string strconn,string strDbName) 
    {
                      string  strs="" ;
   string strsql="";    strsql = strsql+"use " +strDbName;
FileStream fileSQL=new FileStream(strFile,FileMode.Open);
StreamReader sr=new StreamReader(fileSQL);
string line="";
do
{
line=sr.ReadLine();
strs=strs+line;
}
while(line!=null);
strsql=strsql+strs;                                     sr.close;
SqlConnection connConnection;
connConnection = new SqlConnection(strconn);
SqlCommand myCommands=new SqlCommand(strsql,connConnection);
try {
connConnection.Open();
myCommands.ExecuteNonQuery();
}
catch(Exception e)
{
lblMessage.Text=e.ToString();
}
finally
{
connConnection.Close();
}
   
    }
其中在strs=strs+line;
这个语句中要加如vb那样的chr(10)+chr(13)
在c#中如何实现返回与字符代码相关的字符??????
再次感谢大家!!!!

解决方案 »

  1.   

    MessageBox.Show("\x41\x42\x43");  输出ABC  \x41  41是65的十六进制表示法,65是A的ascii码\r回车=chr(13)
    \n换行=chr(10)
      

  2.   

    MessageBox.Show("\u9648");输出"陈",  9468是陈的unicode码十六进制表示。
      

  3.   

    MessageBox.Show("\x41\x42\x43")这里是用16进制表示的。
    A  \41
    B  \42
    ...
    具体参考编码表
      

  4.   

    我的意思
    是不是用这个来输出MessageBox.Show
    而是strs=strs+line+chr(10)+chr(13);
    也就是每DO while循环一次都要
    回车和换行
      

  5.   

    这样没有用的
    要构成一条SQL语句执行
      

  6.   

    do
    {
    line=sr.ReadLine();
    strs=strs+line;
    }
    while(line!=null);
    strsql=strsql+strs;
      

  7.   

    strs=strs+line+"\n\r";只是这样就行了!!