本文介绍了什么类型的ASP.NET(C#)架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello Code Project,
最近,我检查了C#.Net中的N-Tier架构。我想问一下(新手问题),当我将dbLayer类放入我的应用程序/ web时,所使用的架构是什么?
dbLayer.cs中的示例代码
使用系统;
使用 System.Collections;
使用 System.Collections.Generic;
使用 System.Data;
使用 System.Diagnostics;
使用 System.Data.Sql;
使用 System.Data.SqlClient;
使用 System.Text;
使用 System.IO;
使用 System.Web;
使用 System.Net;
/// < 摘要 >
/// dbLayer的摘要说明
/// < / summary >
public class dbLayer
{
private string gConnString;
public dbLayer( string strConnn)
{
gConnString = strConnn ;
}
public void WebConfig_ActivityLog( string username, string activity)
{
SqlConnection sqlConn = new SqlConnection();
SqlCommand sqlCmd = new SqlCommand();
sqlConn.ConnectionString = gConnString;
sqlCmd.CommandText = dbo。[sp_Activity_Trail];
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Connection = sqlConn;
sqlCmd.Parameters.Add( new System.Data.SqlClient.SqlParameter( @ username,SqlDbType.VarChar, 255 ));
sqlCmd.Parameters.Add( new System.Data.SqlClient.SqlParameter( @ activity,SqlDbType.VarChar, 4000 ));
sqlCmd.Parameters [ @ username]。Value = username;
sqlCmd.Parameters [ @ activity]。Value = activity;
尝试
{
sqlConn.Open();
sqlCmd.ExecuteNonQuery();
}
catch (例外objExp)
{
throw objExp;
}
最后
{
if (sqlConn != null && sqlConn.State!= System.Data.ConnectionState.Closed)
{
sqlConn.Close();
}
}
}
}
谢谢!
我尝试了什么:
从不同架构确认和检查谷歌。
解决方案
Hello Code Project,
Recently, I checked the N-Tier Architecture in C#.Net. I would like to ask (newbie question) if what architecture used is when I put dbLayer class in my application/web?
Example code in dbLayer.cs
using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.Data.Sql; using System.Data.SqlClient; using System.Text; using System.IO; using System.Web; using System.Net; /// <summary> /// Summary description for dbLayer /// </summary> public class dbLayer { private string gConnString; public dbLayer(string strConnn) { gConnString = strConnn; } public void WebConfig_ActivityLog(string username, string activity) { SqlConnection sqlConn = new SqlConnection(); SqlCommand sqlCmd = new SqlCommand(); sqlConn.ConnectionString = gConnString; sqlCmd.CommandText = "dbo.[sp_Activity_Trail]"; sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Connection = sqlConn; sqlCmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@username", SqlDbType.VarChar, 255)); sqlCmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@activity", SqlDbType.VarChar, 4000)); sqlCmd.Parameters["@username"].Value = username; sqlCmd.Parameters["@activity"].Value = activity; try { sqlConn.Open(); sqlCmd.ExecuteNonQuery(); } catch (Exception objExp) { throw objExp; } finally { if (sqlConn != null && sqlConn.State != System.Data.ConnectionState.Closed) { sqlConn.Close(); } } } }
Thank you!
What I have tried:
Confirmation and checking google from different architecture.
解决方案
这篇关于什么类型的ASP.NET(C#)架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!