我尝试使用webform gridview上的文本框来构建搜索功能,该文本框填充来自远程mysql数据库的记录。 我遇到了语法错误,但是当我查看手册并尝试遵循正确的语法时,错误仍然存在。 我使用Asp.net 2013和远程mysql数据库。
public partial class resitDB : System.Web.UI.Page
{
string myConn = "SERVER=110.4.**.***;PORT=****;DATABASE= ***** ;UID=**** ;PASSWORD=***** ;";
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Session["username"].ToString();
if (!IsPostBack)
{
using (MySqlConnection conn = new MySqlConnection(myConn))
{
using (MySqlCommand com = new MySqlCommand("SELECT * FROM `tblresit`", conn))
{
using (MySqlDataAdapter da = new MySqlDataAdapter())
{
com.Connection = conn;
da.SelectCommand = com;
using (DataTable dt = new DataTable())
{
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
}
}
//here
searchData("");
}
public void searchData(string valueSearch)
{
//the sql error is here
string query = "SELECT * FROM 'tblresit' WHERE CONCAT ('custName','IdResit','resitId','custId') LIKE '%"+valueSearch+"%' )";
MySqlConnection con = new MySqlConnection(myConn);
MySqlCommand com = new MySqlCommand(query, con);
MySqlDataAdapter adapter = new MySqlDataAdapter(com);
dt = new DataTable();
adapter.Fill(dt);
GridView1.DataSource = dt;
}
protected void searchBtn_Click(object sender, EventArgs e)
{
string valueSearch = searchTxt.Text.ToString();
searchData(valueSearch);
}
}
答案 0 :(得分:0)
我的猜测是你想写类似
的东西Sub T1()
Dim sourceTitle As Range, targetTitle As Range
Set sourceTitle = Workbooks("Data to Copy.xlsm").Worksheets(2).Columns("B")
Set targetTitle = Workbooks("Data Destination.xlsm").Worksheets(1).Columns("C")
Set sourceProject = Workbooks("Data to Copy.xlsm").Worksheets(2).Columns("C")
Set targetProject = Workbooks("Data
Destination.xlsm").Worksheets(1).Columns("D")
Set sourcePM = Workbooks("Data to Copy.xlsm").Worksheets(2).Columns("D")
Set targetPM = Workbooks("Data Destination.xlsm").Worksheets(1).Columns("I")
Set sourceBusiness = Workbooks("Data to Copy.xlsm").Worksheets(2).Columns("E")
Set targetBusiness = Workbooks("Data Destination.xlsm").Worksheets(1).Columns("K")
Set sourceHigh = Workbooks("Data to Copy.xlsm").Worksheets(2).Columns("F")
Set targetHigh = Workbooks("Data Destination.xlsm").Worksheets(1).Columns("L")
Set sourceE0 = Workbooks("Data to Copy.xlsm").Worksheets(2).Columns("G")
Set targetE0 = Workbooks("Data Destination.xlsm").Worksheets(1).Columns("S")
Set sourceActual = Workbooks("Data to Copy.xlsm").Worksheets(2).Columns("H")
Set targetActual = Workbooks("Data Destination.xlsm").Worksheets(1).Columns("V")
sourceTitle.Copy Destination:=targetTitle
sourceProject.Copy Destination:=targetProject
sourcePM.Copy Destination:=targetPM
sourceBusiness.Copy Destination:=targetBusiness
sourceHigh.Copy Destination:=targetHigh
sourceE0.Copy Destination:=targetE0
sourceActual.Copy Destination:=targetActual
End Sub