There is an error message when uploding files to Database.
-
connString = "Provider=SQLOLEDB;Data Source = db.incheonlaw.ac.kr; Initial Catalog=stanlee;User ID=stanlee;Password=stan;"; 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(); } All data of Writing_Num, FileName, FileSize, ContentType, FileData are normally operating. and when debuging "cmd.ExecuteNonQuery()", there is an error message, "Must declare the variable "@Writing_Num"; at this codes: catch (Exception ex) { buffer.Append("<li>Error Occurred: "); buffer.Append(ex.Message).Append("</li>"); }
-
connString = "Provider=SQLOLEDB;Data Source = db.incheonlaw.ac.kr; Initial Catalog=stanlee;User ID=stanlee;Password=stan;"; 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(); } All data of Writing_Num, FileName, FileSize, ContentType, FileData are normally operating. and when debuging "cmd.ExecuteNonQuery()", there is an error message, "Must declare the variable "@Writing_Num"; at this codes: catch (Exception ex) { buffer.Append("<li>Error Occurred: "); buffer.Append(ex.Message).Append("</li>"); }
adding cmd.Parameters.AddRange(pms.ToArray()); before con.Open would help
In Word you can only store 2 bytes. That is why I use Writer.
-
adding cmd.Parameters.AddRange(pms.ToArray()); before con.Open would help
In Word you can only store 2 bytes. That is why I use Writer.
There is no ToArray in components of pms. ERROR!! T^T....
-
There is no ToArray in components of pms. ERROR!! T^T....
then add each pms defined to cmd.parameters.Add() or did you try cmd.parameters.AddRange(pms) ?
In Word you can only store 2 bytes. That is why I use Writer.
-
connString = "Provider=SQLOLEDB;Data Source = db.incheonlaw.ac.kr; Initial Catalog=stanlee;User ID=stanlee;Password=stan;"; 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(); } All data of Writing_Num, FileName, FileSize, ContentType, FileData are normally operating. and when debuging "cmd.ExecuteNonQuery()", there is an error message, "Must declare the variable "@Writing_Num"; at this codes: catch (Exception ex) { buffer.Append("<li>Error Occurred: "); buffer.Append(ex.Message).Append("</li>"); }
How about not setting pms to null after you've put stuff in it?
var question = (_2b || !(_2b));