我正在尝试创建一个搜索,当用户搜索带有冒号的内容时,将返回错误。这就是我到目前为止对代码的任何改进都会很棒!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
namespace Assignment1
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SUBMIT_Click(object sender, EventArgs e)
{
{
string sConnection = "Data Source=labsql;Integrated Security=True;database=master";
SqlConnection dbConn;
dbConn = new SqlConnection(sConnection);
dbConn.Open();
string sql = "SELECT * FROM you_found_the_easter_egg WHERE Message LIKE '%" + DataInputBox.Text + "%' OR IsThisFunnyToJeff LIKE '%" + DataInputBox.Text + "%' OR George LIKE '%" + DataInputBox.Text + "%';";
SqlCommand dbCmd = new SqlCommand(sql);
dbCmd.Connection = dbConn;
SqlDataReader reader = dbCmd.ExecuteReader();
while (reader.Read())
reader.Close();
dbCmd.ExecuteNonQuery();
dbConn.Close();
}
}
}
}
另外,在呈现结果方面我应该使用什么?列表框是否是呈现结果的最简单方法?
答案 0 :(得分:0)
public interface IUser
{
[JsonProperty("id")]
string DocumentId { get; set; }
[JsonProperty("created")]
DateTimeOffset Created { get; set; }
[JsonProperty("modified")]
DateTimeOffset Modified { get; set; }
[JsonProperty("email")]
string Email { get; set; }
...
}