- PR -

データグリッド。。

1
投稿者投稿内容
てろ
会議室デビュー日: 2003/05/12
投稿数: 14
投稿日時: 2003-05-12 10:26
こんにちは。
テキストボックスに入力した文字でデータベースから検索してデータグリッドに表示させたいのですが、どのようにすればいいのでしょうか?
よろしくお願いいたします。
ダンクーガ
常連さん
会議室デビュー日: 2003/03/14
投稿数: 48
お住まい・勤務地: 千葉県
投稿日時: 2003-05-12 11:32
Buttonのイベントにこんな感じの記述でOKだと思います。これはVB.NETで記述しましたがC#でもそんなに変わらないと思いますよ。


DataGrid1.Visible = True

Dim Search As String
Dim Search2 As String
Dim connectionString As String = "User Id=cportal;Password=111111;Data Source=orasea_sqlserver;"
Dim ds As DataSet = New DataSet("Shop")

Search = TextBox1.Text
Search2 = TextBox2.Text

If Search = "" Then Search = 0
If Search2 = "" Then Search2 = 9999999999999

AD = New OracleDataAdapter(Command)
Connection = New OracleConnection(connectionString)

Connection.Open()

Command = New OracleCommand()
Command.Connection = Connection
Command.CommandType = CommandType.Text
Command.CommandText = "Select 店舗コード,店舗名,住所,電話番号,フラグ From Shop where 店舗コード between "
Command.CommandText += Search
Command.CommandText += " and "
Command.CommandText += Search2
AD = New OracleDataAdapter(Command)
AD.Fill(ds)
DataGrid1.DataSource = ds
DataGrid1.DataBind()

Connection.Close()
てろ
会議室デビュー日: 2003/05/12
投稿数: 14
投稿日時: 2003-05-12 12:19
早速お答えいただいてありがとうございます。
たすかりましたm(_ _)m
1

スキルアップ/キャリアアップ(JOB@IT)