zoukankan      html  css  js  c++  java
  • C#中SQL语句参数写法

    OracleConnection oc=new OracleConnection("data source=osserver;User Id=****;password=**");
    OracleCommand cmd=new OracleCommand("insert into cym1.uploadfile (filename,filecontent) values (:filename,:filecontent)",oc);
    OracleParameter op1=new OracleParameter("filename",OracleType.VarChar,256);
    OracleParameter op2=new OracleParameter("filecontent",OracleType.Blob,filedata.Length);
    op1.Value=System.IO.Path.GetFileName(File1.Value);
    cmd.Parameters.Add(op1);
    op2.Value=filedata;
    cmd.Parameters.Add(op2);
    oc.Open();
    cmd.ExecuteNonQuery();
    oc.Close();
    在ORACLE中,SQL语句参数是:+参数名,
    insert into cym1.uploadfile (filename,filecontent) values (:filename,:filecontent)
    在定义此参数的参数变量里面参数名不用写:
    OracleParameter op1=new OracleParameter("filename",OracleType.VarChar,256);
    SqlConnection conn=new SqlConnection("data source=ccserver;user id=sa;password=****;initial catalog=cym1");
    SqlCommand cmd =new SqlCommand("insert into uploadfile (filename) values (@filename)",conn);
    SqlParameter sp=new SqlParameter("@filename",SqlDbType.VarChar,256);
    sp.Value="1.jpg";
    conn.Open();
    cmd.ExecuteNonQuery();
    conn.Close();
    在SQLSERVER中,SQL语句参数是@+参数名,
    insert into uploadfile (filename) values (@filename)
    在定义此参数的参数变量里面参数要写@
    SqlParameter sp=new SqlParameter("@filename",SqlDbType.VarChar,256);

  • 相关阅读:
    流程控制语句
    lminus
    TCL create list from file
    DFT 问答 III
    DFT 问答 II
    DFT 问答 I
    猜字符小游戏
    用户模式构造
    基元线程同步构造
    七大原则,24种设计模式
  • 原文地址:https://www.cnblogs.com/wwwzzg168/p/3569136.html
Copyright © 2011-2022 走看看