【发布时间】:2018-12-06 02:08:25
【问题描述】:
所以上个月我正在与 NopCommerce 合作,但我正在尝试制作一个旅游网站,这有点困难,所以我有一个连接到数据库并进行 SELECT 的代码:
public string cs_preorder_proc(int opcode, string p1, string p2)
{
string reto1 = "**";
String connectionString = "connectionstring";
//String sql = "SELECT * FROM dbo.OrderRecord";
String sql = "SELECT * FROM dbo.CS_Orders";
var model = new List<Product>();
//using (SqlConnection conn = new SqlConnection(connectionString))
SqlConnection conn = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader rdr = cmd.ExecuteReader();
bool b1 = true;
int itotraws = 0;
int itotporpag = 50;
while (b1 && itotraws < itotporpag)
{
itotraws ++;
b1 =rdr.Read();
if (b1)
{
string a1 = "";
string a2 = "";
string a3 = "";
string a4 = "";
string a5 = "";
string a6 = "";
a1 = rdr["ProductName"].ToString();
a2 = rdr["Price"].ToString();
a3 = rdr["PersonsNumber"].ToString();
a4 = rdr["Date"].ToString();
a5 = rdr["TourType"].ToString();
a6 = rdr["CarsNumber"].ToString();
}
}
return reto1;
}
现在我想在一个新的 View 中展示它,但我不知道我是否需要使用 get ; set 创建一个模型,或者它存在更好的方法来做到这一点。
【问题讨论】:
-
nopCommerce 中没有
OrderRecord和CS_Orders等表名,你想实现什么.. 问题我不清楚! -
此条件:
while (b1 && itotraws < itotporpag)用于?您的连接字符串来自哪里? -
非常不好用纯文本
SELECT *
标签: sql razor asp.net-core nopcommerce