急求!关于在asp.net写搜索框
我想做一个搜索框,用户在框中输入内容,按确定后就把相应搜索结果显示在repeater里,下面是我写的代码,各位高手看看什么问题,指点啊···
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["register"].ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from aa where content like '%@content%'";
cmd.Connection = con;
cmd.Parameters.Add(new SqlParameter("@content", TextBox1.Text));
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
con.Open();
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
Repeater1.DataSource = ds;
Repeater1.DataBind();
我想问题就在于cmd.CommandText = "select * from aa where content like '%@content%'";这句,我试过cmd.CommandText = "select * from aa" 这样子是没有问题的,但我不知道怎么改。
select * from aa where content like '%"+@content+"%'";
"select * from aa where content like '%"+content%+"
相关问答:
select top 12 * from Product where [id] not in (select top 12 [id] from Product)
这样可以分页,但是我在后面想加个条件
select top 12 * from Product where [id] not in (select top 12 [id] from Prod ......
<script type="text/javascript" src="js/Dialog.js"></script>
<script type="text/javascript">
function zOpenD()
{
va ......
我主要想控制下word保存的地址,但是编译不过去,总觉得是缺了using。。。
谢谢
代码如下:
using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Data;
u ......
asp.net ajax中updatepanel里面的控件里面有个button和若干textbox
我点击button验证信息出现,但是就是无法拦截我button后面运行的事件!
验证的代码是JS验证还是.net中的验证控件,或是按钮事件中的后台验证?
......
function CheckOpwd(){//验证用户名
var pwd=document.all.txtOpwd;
var div1=document.getElementById("divPwd");
if (pwd.value=="")
{
......