c#
【摘要】
1.MySql连接
<connectionStrings>
<add name="mysql" connectionString="server=localhost;port=3306;user id=zzzili;password=zzzili123;database=z...
1.MySql连接
<connectionStrings>
<add name="mysql" connectionString="server=localhost;port=3306;user id=zzzili;password=zzzili123;database=zzzili;CharSet=gb2312;" providerName="MySql.Data.MySqlClient"/>
</connectionStrings>
private string mysqlYunfeng = System.Configuration.ConfigurationManager.ConnectionStrings["mysql"].ConnectionString;
2.数据操作
using (MySqlDataReader dr = MySqlHelper.ExecuteReader(mysqlYunfeng, sql))
{
if (dr.HasRows == true)
{
while (dr.Read())
{
if (dr[0].ToString() == "Logo")
{
node.LogoVersion = dr[1].ToString();
}
else if (dr[0].ToString() == "City")
{
node.CityVersion = dr[1].ToString();
}
}
}
}
MySqlParameter[] paras = new MySqlParameter[4];
paras[0] = new MySqlParameter("@stuNum",stuNum);
paras[1] = new MySqlParameter("@answer",answer);
paras[2] = new MySqlParameter("@score",score);
paras[3] = new MySqlParameter("@exid",ex_id);
3.Json序列化
//JavaScriptSerializer类在System.Web.Extensions.dll中,注意添加这个引用
JavaScriptSerializer serializer = new JavaScriptSerializer();
//JSON序列化
string result = serializer.Serialize(node);
4.Request.QueryString[""].ToString();
5.输出调试信息
System.Diagnostics.Debug.WriteLine(returnStr);
6.sql中的判断
select case when a>b then a
when b>c then b
esle c end
from table_name
where ...
7.web Table写入Excel
protected void Button1_Click(object sender, EventArgs e)
{
BndTableList(this.txtTime.Text, null);
StringBuilder tstr = new StringBuilder();
foreach (TableRow row in Table1.Rows)
{
foreach (TableCell cell in row.Cells)
{
tstr.AppendFormat("{0} ",cell.Text);
}
tstr.Append("\r\n");
}
WriteFile(tstr.ToString());
}
private void WriteFile(string str)
{
System.IO.File.WriteAllText("C:\\upload\\aaa.xls", str, Encoding.UTF8);
}
8.方法不在Swagger文档中显示
[HttpPost]
[ApiExplorerSettings(IgnoreApi = true)]
public void Test(){
//*************
}
文章来源: zzzili.blog.csdn.net,作者:清雨小竹,版权归原作者所有,如需转载,请联系作者。
原文链接:zzzili.blog.csdn.net/article/details/19191483
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)