Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. when using .mdb to upload files, it was good. but....in MSSQL..

when using .mdb to upload files, it was good. but....in MSSQL..

Scheduled Pinned Locked Moved ASP.NET
questiondatabasesql-serverhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lsh486love
    wrote on last edited by
    #1

    Originally, I declared to use mdb for uploading files like the following codes before changing. //connString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+ // MapPath("Files.mdb"); I declared like this for using to upload files to MSSQL : connString = "Provider=SQLOLEDB;Data Source = db.incheonlaw.ac.kr; Initial Catalog=stanlee;User ID=stanlee;Password=stan;"; After changing codes, there is an error, Must declare the variable "@Writing_Num". when debuging this part, "cmd.ExecuteNonQuery();"........ using (OleDbConnection con = new OleDbConnection(ConnectionString)) using (OleDbCommand cmd = new OleDbCommand(CmdText, con)) { OleDbParameterCollection pms = cmd.Parameters; pms.Add("@Writing_Num", OleDbType.VarChar, 50); pms.Add("@FileName", OleDbType.VarChar, 200); pms.Add("@FileSize", OleDbType.Integer); pms.Add("@ContentType", OleDbType.VarChar, 50); pms.Add("@FileData", OleDbType.VarBinary); pms["@Writing_Num"].Value = writing_num; pms["@FileName"].Value = fileName; pms["@FileSize"].Value = fileLength; pms["@ContentType"].Value = contentType; pms["@FileData"].Value = fileData; pms = null; con.Open(); cmd.ExecuteNonQuery(); } How can I properly use mssql??? Is there something wrong??

    E 1 Reply Last reply
    0
    • L lsh486love

      Originally, I declared to use mdb for uploading files like the following codes before changing. //connString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+ // MapPath("Files.mdb"); I declared like this for using to upload files to MSSQL : connString = "Provider=SQLOLEDB;Data Source = db.incheonlaw.ac.kr; Initial Catalog=stanlee;User ID=stanlee;Password=stan;"; After changing codes, there is an error, Must declare the variable "@Writing_Num". when debuging this part, "cmd.ExecuteNonQuery();"........ using (OleDbConnection con = new OleDbConnection(ConnectionString)) using (OleDbCommand cmd = new OleDbCommand(CmdText, con)) { OleDbParameterCollection pms = cmd.Parameters; pms.Add("@Writing_Num", OleDbType.VarChar, 50); pms.Add("@FileName", OleDbType.VarChar, 200); pms.Add("@FileSize", OleDbType.Integer); pms.Add("@ContentType", OleDbType.VarChar, 50); pms.Add("@FileData", OleDbType.VarBinary); pms["@Writing_Num"].Value = writing_num; pms["@FileName"].Value = fileName; pms["@FileSize"].Value = fileLength; pms["@ContentType"].Value = contentType; pms["@FileData"].Value = fileData; pms = null; con.Open(); cmd.ExecuteNonQuery(); } How can I properly use mssql??? Is there something wrong??

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      OLEDB is deprecated you should probably use ODBC to connect if you can (and you can) but more to the point your parameter Writing_Num probably doesn't exist in your command, which you did not provide.

      Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups