Windows Develop Bookmark and Share   
 index > Windows Forms General > how to insert string "ALL " in combobox (while trying to retrieve column which is of date datatype)
 

how to insert string "ALL " in combobox (while trying to retrieve column which is of date datatype)

hi,

Ii used data table to retrive column which is of datatype date from database,

when i try to insert string "ALL" as first index it doesn't takes,

dim brow as DataRow=dt.NewRow

brow(0)="ALL"

dt.rows.InsertAt(brow,0)

Please help me

ZACK2K6  Sunday, April 16, 2006 11:45 AM

I assume you are using the combobox to supply criteria to perform some query.

Typically, criteria is applied only if a value isn't supplied. .. text = " for text boxes/value is null for combos.

so,given table is mytable, field is datefield, desired format is mm/dd/yyyy and you are using SQL Server, fill your combo with:


select * from (

SELECT 'All' DateDisplay, null DateValue

union

SELECT convert(sysname, datefield, 101), datefield from mytable

) temp order by DateValue


Set displayMember to DateDisplay, ValueMember to DateValue

Blair Allen Stark  Sunday, April 16, 2006 5:37 PM

Please help me,

When i try to insert String "ALL" in combo box , i have no result

Iam using the combobox to supply criteria to perform some query.

so,given table is Barcodeinfo, field is date_id which is date /time data type , desired format is mm/dd/yyyy andalso

i want to display the time, combo box name cboDate using MS Access,


sql = "select distinct date_id from Barcodeinfo"

cboDate.DataSource = NecCls.FillComboStr1(sql)

cboDate.DisplayMember = "date_id"

cboDate.ValueMember = "date_id"

cboDate.SelectedIndex = 0

Public Function FillComboStr1(ByVal CSql As String) As DataTable

Dim myCommand As OleDbCommand

Dim er As String

Try

MyConnection = New OleDbConnection(ConnectionString)

myCommand = New OleDbCommand(CSql, MyConnection)

MyConnection.Open()

Dim myAdapter As New OleDbDataAdapter(myCommand)

Dim dt As New DataTable

'Dim dt As New DataTable("tblUser")

'Dim dset As DataSet

'dset.Tables.Add(dt)

' Return dset

myAdapter.Fill(dt)

Dim bRow As DataRow = dt.NewRow

bRow(0) = "ALL"

dt.Rows.InsertAt(bRow, 0)

Return dt

Catch ex As Exception

errMsg = ex.ToString

' Return Nothing

Finally

MyConnection.Close()

End Try

End Function

Thanks in advance



ZACK2K6  Monday, April 17, 2006 4:32 AM

You can use google to search for other answers

Custom Search

More Threads

• ComboBox does not work
• Listview Column Widths
• Hai friends...I have user controls on panel. I have to delete those controls using ToolStripMenuItem, named, "delete"
• Object->Equals method did not work
• listview item question
• VB2005 Report (rdlc) programmaticaly modify Header data
• Background color TabControl
• Anyone know a free tree control that allows you to set node images?
• Trying to paint on top of a text box control
• Public Enum