首页
论坛
新职位
福彩12选5走势图论坛
什么's new
新职位
新的个人资料帖子
最新活动
会员
目前的访客
新的个人资料帖子
福彩12选5走势图个人资料帖子
VB.NET社区
登录
登记
什么's new
福彩12选5走势图
福彩12选5走势图
仅福彩12选5走势图标题
经过:
新职位
福彩12选5走势图论坛
Menu
Log in
Register
安装应用
安装
首页
论坛
C#
Windows表格
ConnectionString属性尚未初始化
您正在使用过期的浏览器。它可能无法正确显示此网站或其他网站。
您应该升级或使用
替代浏览器
.
回复主题
信息
<blockquote data-quote="andrewmanuja" data-source="post: 14742" data-attributes="member: 11723"><p>Hi Skydiver,</p><p>Thanks for the provided sample code for the recommended method of programming above.</p><p>Got a slight issue which does not capture by my tired eyes.</p><p>This is related to the same project discussed above and when updating a SQL table, I am getting a parameterized query error specifying that '@aissueQuantity' was not supplied.</p><p></p><p>Please find my respective code below;</p><p>[CODE=csharp]SqlConnection connect = Connection.GetConnection();</p><p> table.AcceptChanges();</p><p> //Mark selected rows ready for insert</p><p> foreach (DataRow row in table.Rows)</p><p> {</p><p> if (row["Select Item"] as bool? == true)</p><p> {</p><p> row.SetAdded();</p><p> //row.SetModified();</p><p> }</p><p> }</p><p></p><p> //Save Data to Destination</p><p> </p><p> //Below section add the respective drug quantities to the respective cost centre drug available quantity</p><p> </p><p> using (var command = new SqlCommand(@"UPDATE tbl_CostCentreDrugStock SET tbl_CostCentreDrugStock.availableQuantity += @aissueQuantity</p><p> FROM tbl_CostCentreDrugStock</p><p> INNER JOIN tbl_CostCentreOrderStatus</p><p> ON tbl_CostCentreDrugStock.costCentreID = tbl_CostCentreOrderStatus.costCentreID</p><p> WHERE tbl_CostCentreOrderStatus.ccOrderID =@accOrderID AND tbl_CostCentreDrugStock.drugID =@adrugID ", connect))</p><p></p><p> using (var adapter = new SqlDataAdapter { InsertCommand = command })</p><p> {</p><p> command.Parameters.Add("@adrugID", SqlDbType.Int, 0, "drugID");</p><p> command.Parameters.Add("@accOrderID", SqlDbType.Int, 0, "ccOrderID");</p><p> command.Parameters.Add("@aissueQuantity", SqlDbType.Int, 0, "issueQuantity");</p><p></p><p> try</p><p> {</p><p> adapter.Update(table);</p><p> MessageBox.Show("Data Saved");</p><p> }</p><p> catch (Exception ee)</p><p> {</p><p> MessageBox.Show(ee.Message);</p><p> }[/CODE]</p><p>The SQL table, tbl_CostCentreDrugStock got fields costCentreID, drugID and availableQuantity.</p><p></p><p>Appreciate your valuable feedback.</p><p></p><p>Kind regards,</p><p></p><p>Andrew</p></blockquote><p></p>
Insert quotes…
确认
发表回复
首页
论坛
C#
Windows表格
ConnectionString属性尚未初始化
本网站使用Cookie来帮助个性化内容,调整您的体验并在注册时保持登录状态。
继续使用本网站,即表示您同意我们使用cookie。
接受
了解更多…
最佳
底部