when using .mdb to upload files, it was good. but....in MSSQL..
-
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??
-
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??
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