C#将值从文本框传递到DAL以更新数据库 [英] C# pass value from textbox to DAL to update database

查看:49
本文介绍了C#将值从文本框传递到DAL以更新数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在修改现有的C#程序。在主窗体(MainForm.cs)上,有一个按钮(btnEditName)。当您单击该按钮时,会出现另一个窗口(SaveDescName.cs)。在此表单上是一个文本框(txtInputName),用于输入名称和保存按钮(onClickSave)。此应用程序在数据层中具有现有代码。我在编写从文本框中获取值并将其传递给数据层的代码时遇到了麻烦。在数据层中,我编写了在SQL数据库中更新此字段的代码。有人可以给我一些关于如何编写代码的指导,让文本框中的值传递给DAL进行更新。





数据层代码:(DataLayer.Mortley.CadeyFiles)



公共静态bool UpdateCadeyName(SqlConnectionStringBuilder _sqlConnMyDb,MapDirMortleyFile newFileName)

{

var sqlUpdateFile = CreateUpdateSQLStatement();

.........

}



我尝试过:



当前代码根本不起作用。

I am modifying an existing C# program. On the main form (MainForm.cs), there is a button (btnEditName). When you click that button another window comes up (SaveDescName.cs). On this form is a textbox (txtInputName) to input a name and a save button (onClickSave). This application has existing code in the data layer. I'm having trouble with writing the code that takes the value from the textbox and passing it to the data layer. In the data layer I have written code to Update this field in the SQL Database. Can someone give me some guidance on how to write the code to have the value from the textbox pass to the DAL for the update.


Data Layer code: (DataLayer.Mortley.CadeyFiles)

Public static bool UpdateCadeyName (SqlConnectionStringBuilder _sqlConnMyDb, MapDirMortleyFile newFileName)
{
var sqlUpdateFile = CreateUpdateSQLStatement();
.........
}

What I have tried:

Current code is not working at all.

推荐答案

参考这篇文章

了解C#中的3层体系结构 [ ^ ]

c# - 三层Windows窗体应用程序中的体系结构实现 [ ^ ]
refer this article
Understand 3-Tier Architecture in C#[^]
c# - Three-tier architecture implementation in Windows form application [^]


这篇关于C#将值从文本框传递到DAL以更新数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆