Name
SQL テーブルがあり、その列にユーザーが入力したテキストを含むすべての行を表示したいと考えています。どうやってそうするのですか?
私はVisual Studio 2010でC#でやっています
Name
SQL テーブルがあり、その列にユーザーが入力したテキストを含むすべての行を表示したいと考えています。どうやってそうするのですか?
私はVisual Studio 2010でC#でやっています
Select * from tablename where DATALENGTH(Name) > 0
SQLCommandオブジェクトでこのクエリを試してください。
このクエリを使用してみてください
sqlcommand cmd=new sqlcommand();
cmd="Select * from tablename where Name ='" + textboxid.text + "'";
ここで、tablenameはuが作成したテーブルの名前であり、textboxidはuが名前を入力するテキストボックスのIDです。
これを試してみてください。クエリパラメータを使用しています:
SqlCommand myCommand = new SqlCommand(
string.Format("Select * from Table where Name = @NameInput"), SqlConnection);
SqlParameter param = new SqlParameter();
param.ParameterName = "@NameInput";
param.Value = textbox.Text;
param.SqlDbType = SqlDbType.Char;
myCommand.Parameters.Add(param);
select * from Table where Name is not null
select * from Table where Name is not null and Name<>''