似是而非

导航

Combobox代码

不可编辑代码:

ComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList

 

动态添加代码:

 

写在前面的语句:

Imports System.Data

Imports System.Data.OleDb

――――――――――――――――

连接语句:

Private ds1 As DataSet = New DataSet

Private strcon As String = "Provider=SQLOLEDB.1;Data Source=(local);Initial Catalog=storehouse;User ID=sa;Password=sa"

Public DBcon As New OleDbConnection(strcon)

―――――――――――――――――

DBcon.Open()

Dim sqlStr As String = "SELECT 动态添加的列 FROM 动态添加的表"

Dim adt As New OleDbDataAdapter(sqlStr, DBcon)

ds1.Clear()

   adt.Fill(ds1)

   DBcon.Close()

   ComboBox1.Items.Clear()

   Dim count As Integer = ds1.Tables(0).Rows.Count

   For i As Integer = 0 To count - 1

      ComboBox1.Items.Add(CStr(ds1.Tables(0).Rows(i).Item("动态添加的列")))

   Next i

――――――――――――――――――

posted on 2009-11-25 13:54  似是而非  阅读(297)  评论(0编辑  收藏  举报