c#学习.

项目结构

BLL是业务层
DAL是数据库操作层
Model是模型层
Utility是工具层

链接sqlserver数据库的几种方式

sqlServer   数据库常用连接字符串
用户名和密码验证的方式去连接到数据库服务器
  <add name="conStr" connectionString="Data Source=服务器名;Initial Catalog=数据库名; User Id=用户名;Password=密码"/>  
  <add name="conStr" connectionString="Server=服务器名;Database=数据库名;User Id=用户名;Password=密码"/>  
<add name="conStr" connectionString="server=l服务器名;database=数据库名;uid=用户名;pwd=密码;pooling=true;min pool size=1;max pool size=2;connection reset=true"/>

Windows验证的方式去连接到数据库服务器
   <add name="conStr" connectionString="Data Source=服务器名;Initial Catalog=数据库名;Integrated Security=True;" />
    <add name="conStr" connectionString="Data Source=服务器名;Initial Catalog=数据库名;Integrated Security=SSPI;" />    
   <add name="conStr" connectionString="Data Source=服务器名;Initial Catalog=数据库名;Trusted_Connection = False;Encrypt = yes" />
<add name="conStr" connectionString=" data source=服务器名;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"/>
————————————————
版权声明:本文为CSDN博主「alanciscocn」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/alanciscocn/article/details/105813585

update用户时显示数据未发生改变

if!IsPostBack){
}

js发送json到后台转对象在序列化成xml转发

async function sendDist() {
  try {
    let r = {
      Action: '',
      A: '20210608',
      B: 0,
      C: '2021-06-15',
      //直接用这种方式送数组,简便
      List: JSON.stringify([{ E: 'sjha1234451', F: '1516' },{ E: 'asdasdq57848', F: '11215' }]),
    };
    const form = new FormData();
    Object.keys(r).forEach((k) => form.append(k, r[k]));
    const rs = await axios.post(url, form,{headers: form.getHeaders()});
  } catch (e) {
    console.log(`exp:${e.message}`);
  }
}
//创建对象
[XmlRoot("root")]
	public class A{
		private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
		[XmlElement("B")]
		public string b{ get; set; }
		[XmlElement("outList")]
		public OutList outlists { get; set; }
		[XmlElement("note")]
		public string Note { get; set; }

		public class OutList {
			[XmlElement("list")]
			public List<DList > lists { get; set; }
		}

		public class DList {
			[XmlElement("F")]
			public string f{ get; set; }
			[XmlElement("G")]
			public string g{ get; set; }
			public DList () { }
		}
//拿对象生成xml
public static string GetXml(HttpRequest req) {
			string R = "";
			try {
				A a = new A();
				a.Note = (req["Note"] ?? "").Trim();
				OutList outList = new OutList();
				List<DList > ls = new List<DList >();
				JsonData data = JsonMapper.ToObject((req["OutList"] ?? "").Trim());
				foreach (JsonData j in data) {
					DList l = JsonMapper.ToObject<DistList>(Regex.Unescape(j.ToJson()));
					ls.Add(l);
				}
				outList.lists = ls;
				a.outlists = outList;
				R = a.GetXml();
			} catch (Exception ex) {
				log.ErrorFormat("GetXml异常.原因:{0}", ex.Message);
			}

输出结果


<root>
  <a>202102190002a>
  <b>20210608b>
  <c>0c>
  <d>251000d>
  <outList>
    <list>
      <e>xh10e>
      <f>240f>
    list>
    ...
     <list>
      <e>xh10e>
      <f>240f>
    list>
  outList>
  <note>备注note>
root>

你可能感兴趣的:(asp.net,c#)