Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Date Format Using ADO Data Control And DataGrid


When using the DataGrid with the ADO Data control in VB6 to view info from Access 97 databases, all "Date" fields are shown in US format. How do I display dates in UK "dd/mm/yy" format.(The regional settings in control panel are set correctly for UK dates)Note: Various Recordsets will have the "Date" field in different field positions.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Date Format In Data Grid Control
Hello VB users,

In the Data Grid control, I want to programmatically control the one
column in the date format i.e. DD-MMM-YYYY. I am using the following
where unable to get the desire results. When the column is focused, I
want to show the Masking property like underline and dash sign in this
column.

I used this but not able to get desire result. Anyone can give me sample
code for this.

dg2.Columns(4).DataFormat.Format="dd-mm-yyyy"

Thanks & regards
Arun

Datagrid Date Format
I am using VB6. can you please help me with my problem?

i have a datagrid in my form. on its property, there's a format
for whatever you want to change. i changed the format for the
date. in my datagrid, there's a column for date and i want to
format it to "dd-MMM-yyyy" and i chose this kind of format in
the property. if i run my program the column for my date is
still "dd/mm/yyyy" whenever i retrieve my data. can you please
help me with this? can you give an example? thnk you very much. i am very thankful for you and I really appreciate your help and effort. God Bless



note: in my dbase access the format of the date is "dd-mmm-yy".
if i search a date with a format of "dd-MMM-yyyy", i found a
record. thanks

Help Format Date In Datagrid
So I have a datagrid on a web form and I need to format the date being populated by the access database, the date is being populated with time, This is what it looks like 12/17/1997 12:00:00 AM I just want to take out the time.
Here is my code Can someone help??

Code:
sql = "SELECT DateBacteria, Time, FName, LName FROM bacteria where Envirodat = '" & ddlEnvirodatstring & "'"

        myCommand = New OleDbDataAdapter(sql, conn)
        myCommand.Fill(ds, "bacteria")
        dgBacteria.DataSource = ds
        dgBacteria.DataBind()





Edited by - Lesviper on 3/7/2005 8:47:33 AM

Date Format In DataGrid
Hi,

How can I set the "display format",
                              "input format" and also
                              "output format"
to "dd/mm/yyyy" for a column of a Datagrid which is bind to a database date field.
regardless of the Windows regional setting is either
                              "dd/mm/yyyy" or "mm/dd/yyyy" or even "yyyy/mm/dd"???

Please help!!!

Thanks.

PChan

How To Format A Column Which Holds Date In Datagrid.
A good day to you.

I want to format Column that shows Date in Datagrid as DD/MM/YY but the default format is MM/DD/YYYY. I can set it in MS Access but Datagrid shows different. I tried to set it up in Datagrid Properties but still shows the MM/DD/YYYY format. I have 20 Columns and two columns will be for date and thousands of records that Datagrid will show.

Any help will be highly appreciated.

A Date Format Mask In A Datagrid Column
Hello,

I am a beginner programmer using VB6. I want to apply a date format mask to a column in a datagrid control. Is this possible? I tried the dataformat property and a stddataformat object with no luck. Help!! Code snippets appreciated.

Many thanks,
Trimtrom

How Can I Set Numerical Format On DataGrid Control ?
Dear All !
I'm a beginner with VB. I would like to ask a basic question.

1. How can i set numerical format on DataGrid ?

Some columns on DataGrid is numerical, and i would like to format it , for example 1,000.00. I also set properties of DataGrid, but i don't know why, it alway appear 1000 , like this. I don't know why I can not format appearance of DataGrid.

ANybody know why? or how to do it ! PLease show me !

- I Create a table named 'TestTab' in Database SQLServer
- I use ADODB to connect to Database
- I make a query to TestTab -> Set rs = Conn.Execute("Select * from TestTab")
- And then i set DataGrid.Datasource = rs
- data on DataGrid display is ok, but i can not change the format of numerical column.

Please show me how and why ?

Thank you

hntin

Format Month In Date Data
G'day,

I have a problem - I am extracting dates from the database but the date format is dd/mm/yyyy. What I need is to format the date to read dd MMM yy.

I have been reading and looking up on the web. I know that the "mm" must be extraced by the use of DatePart, formatted to MMM and then replaced into the date, but I have no idea where to start this process.

Any help or direction as to where I should look for the information to complete this process would be appreciated.

Date Format In Data Report
Hi, I use Label in data report to show the date. I use like this : Date %D. It will appear like this Thursday , 31 October 2002. I want it to appear like this : 21 October 2002. Can anybody help me . Thx

Help!!! To Copy Data Of Datagrid In Notepad In Table Format
Dear friends

I want to copy the contents of datagrid in table from in notepad but i do not know how to do it.

Plz!!! help its urgent


Thanks in advance

Shivpreet2k1

Calendar Control Date Format Help
Hi

is there any way to change the date format of a calendar control from code, i have a calendar control with a label an my form when you click the day on the calendar the the date is displayed in the label, all good and well, but i would like to change the date format so that 12-Apr-2006 (wed) is displayed in the label. I have tried in the form load something like

calendar1.value = Date(Now,"dd-mmm-yyyy",(ddd)

but no matter what format i use it always takes the system date, please can someone advise me.

Many thanks

Get Date Format In Control Panel
In VB6, how to get date format from setting in control panel (example: dd/mm/yyyy, mm/dd/yyyy,...)?
Thank you.

Date Format Active X Control
I am using the calender from windows common controls 2 6.0 and i need it to change the format from mm/dd/yyyy to yyyy/mm/dd, and then when a date is clicked on i need it to put it in a text file. I changed the settings of the calender through the properties window to the propper format and that did not work. I can get the date to appear in the text box on click with no problems, however it is not propperly formatted. If anyone knows of anything that i may be missing or may not know i would appreciate it. Thanks ahead of time.

Change Short Date Format To Long Date Format (windows Api?)
i want that when i load my program, it will change the date settings in my computer (short date to long date). How can i do that?

Oddball Date / Time Data Format
Hi gang,

I am trying to write a query for a MAS 200 database.

It is definitely not Microsoft SQL compatible.

Far as I can see date formats are stored in a 6 byte field (Numerical?)
and Time formats are stored in a 4 byte string. (0815, 1430, 2100, Etc...)

Where I am having difficulty is that I need to query from a date and time to a date and time. Combining the given Date and Time fields so I do a comparison keeps failing. I guess I don't see how to convert the string of time characters into a numerical in this version of SQL.

Any thoughts?

~T

Data Bound Grid Date Format
Is it possible to set the date format for the columns of a data bound grid (DAO)?

Right now, I have short date as the default format, but it comes up with 8/28//2002...

But I want it to be 28/08/02 instead.

Can this be done without setting the regional settings? I don't want it to change whenever the system changes regions.... thanks.

Move Data From Datagrid To A Rich Text Format File
i wanna copy data shown in datagrid to a rich text format file
as a report to be printed
please elaborate a bit

thx....

Date Format Question With Calendar Control
I have a two-pronged question:
I have a form that is popping up the Calendar Control Form. It is working great with the following code:
frmEntry.maindate = Format$(CalendarA.Value,"mm/dd/yyyy")

Question one - when I select the date I have to click on the Month then the Year then the day. If I select the Month then the day followed by the year the Calendar value returns the month and day selected, but it returns the current year instead of the year selected. Is there a way to force the date to stay as the date selected no matter what order the user does the selections or am I stuck with the month, year, day input sequence?

Question two - some users are going to want to enter the date rather than use the pop-up. I have the field defined as mm/dd/yyyy. If the user inputs the date as mmddyyyy is there a way to stop an error from happening and reformat the numeric string to be the date string format I am expecting ?

Thank you,

Jennifer

More Date Format Issues (Monthview Control)
I have an earlier post on this board about sending dates to Oracle.

I decided to fix my program but I have one fairly large issue. My entire program revolves around a monthview control. This monthview control sends dates to a million different parts of my program. At one point it even formats a date as part of a unique ID (e.g. 051101xxxxx)

As a test I went into my regional settings and changed my date formats in Windows, and as expected that gummed up my monthview control (and all the code that uses it's values) pretty badly.

When I use a format statment to alter the format of the Monthview control it completely ignores it.

What's up with this. Do I need to specify a FORMAT statment everywhere a date is used in my program so that the users regional settings don't screw everything up?

Custom Format With Date/Time Picker Control
How do you get the date/time picker control to display time in a format such as 'h:mm ampm'? I have set the format of the control to custom and put the format in the CustomFormat property, but the ampm part dosen't seem to work properly. It looks like it is confusing the m's in 'ampm' with minutes. Is there a proper mask or escape character to do this?? Is it even possible at all? Any help is appreciated

Custom Format Date/time Picker Control
Hi Guys,

Im a newbie to the VB world, im trying to custom format the date time picker control so that it highlights/displays the monday of the current week.

Any help would be appreciated!

Change Date Format In Regional Setting Of Control Panel Through VB6
Is there any way to Change the date format in Regional Setting of
Contral Panel through VB6

thx in advance..

--


Best Regards,
Sachin Jain

DATE Problems - Change Date Format To European, Get Current Date, Subtract 2 Dates?
Need someone to point me in the right direction/start me off with this please as I am quite clueless on it at present...

I need something that can successfully subtract two dates...


eg. calculate the difference between the current date
02/04/04 (2nd April 04) and 29/03/04 (28th March 04)
...
which will then output a result of 5 days


So what I need to know is...

1.
I need to know how to get the current date from the system clock

2.
I must somehow get my date function converted into European date format (as at present it is in USA format ie. 2nd April 04 is 04/02/04 like April 2nd 04 which is not good!)

3.
and then I must actually SUBTRACT the 2 dates (the current date and a date that is given) from each other to give an integer which I can then use (ie. a value like 5 or 15).


But I have little idea how to go about this


Can anyone please start me off?

DATE Problems - Change Date Format To European, Get Current Date, Subtract 2 Dates?
Need someone to point me in the right direction/start me off with this please as I am quite clueless on it at present...

I need something that can successfully subtract two dates...


eg. calculate the difference between the current date
     02/04/04 (2nd April 04) and 29/03/04 (28th March 04)
     ...
     which will then output a result of 5 days


So what I need to know is...

1.
I need to know how to get the current date from the system clock

2.
I must somehow get my date function converted into European date format (as at present it is in USA format ie. 2nd April 04 is 04/02/04 like April 2nd 04 which is not good!)

3.
and then I must actually SUBTRACT the 2 dates (the current date and a date that is given) from each other to give an integer which I can then use (ie. a value like 5 or 15).


But I have little idea how to go about this


Can anyone please start me off?

How To Read Specific Excel Range Data Into Datagrid Using Two Date Values?
Hi,

Below is the code that reads a row of Excel data from an Excel File into Visual Basic.NET program datagrid, the code only reads one row of data. I want to add more functionality to the program, on the first column of each rows in the Excel file is date, by adding two datetimepicker in the VB.NET program one listed as start date and other end date. I would like datagrid to return all the data between this two dates, I have trying various scenarios but all unsuccessful. Hope someone can help me.


  Dim oExcel As Object
  Dim i As Integer

        Dim ds As New DataSet
        ds = DataSet1
        ds.Clear()
        DataGrid1.DataSource = Nothing

        oExcel = CreateObject("Excel.Application")

        Dim dr As DataRow
        oExcel.Workbooks.Open(Application.StartupPath & "MyExcel.xls", , False)


        With oExcel.WorkBooks("MyExcel.xls").Worksheets(cmbBox2.SelectedItem)

            dr = ds.Tables("Table1").NewRow

            dr.Item("Date") = .Cells(1, 1).Value
            dr.Item("Min Price") = .Cells(1, 2).Value
            dr.Item("Max Price") = .Cells(1, 3).Value
            dr.Item("Closed Price") = .Cells(1, 4).Value
            dr.Item("Change") = .Cells(1, 5).Value
            dr.Item("Volume") = .Cells(1, 6).Value
            dr.Item("Foreign Inv.") = .Cells(1, 7).Value
            dr.Item("Securities Trust Co.") = .Cells(1, 8).Value
            dr.Item("Dealers") = .Cells(1, 9).Value

            ds.Tables("table1").Rows.Add(dr)

        End With

        Me.DataGrid1.DataSource = ds.Tables("table1")
        Me.DataGrid1.Refresh()

        oExcel.WorkBooks("MyExcel.xls").Close(True)
        oExcel.Quit()
        oExcel = Nothing
        GC.Collect()



Edited by - roniwu on 11/13/2005 6:04:22 AM

Data Format For A Text Box Control
Hello Everyone,
Can anyone tell me how to prefix the data displayed in a textbox with a currency symbol (ex: £) automatically. I tried with it's DataFormat property, but that only checks to see if teh bindable object is a currency datatype or not? My Textbox is'nt databound.
Is there any other way to achieve.
Any help/guidance is greatly appreciated.
Thanks in advance.
K Lloyd

Database Format Not Recognised In Data Control
I have been trying to use the data control in VB to connect to the Access 2000. But somehow when I clicked on the recordsource property, the VB tells me that it is the database format is not recognised. Any advice ?

DATE Problem - Formatting US Date MM/DD/YY To European Date Format DD/MM/YY
I have a problem whereby the user must enter a date into a field...

The system changes the date format to US standard which is MM/DD/YY
but I need to change the format to DD/MM/YY (European standard)


I have done this using the Format function, but I still have a slight problem
Format(mydate,"dd/mm/yy")

doesnt account for all dates...

for example...
if I enter 31/03/04 this is fine, it will accept it as that

However, if I enter 02/04/04 (todays date - 2nd April 04), it will change it to 04/02/04



Any ideas how I can counter this from happening?

DATE Problem - Formatting US Date MM/DD/YY To European Date Format DD/MM/YY
I have a problem whereby the user must enter a date into a field...

The system changes the date format to US standard which is MM/DD/YY
but I need to change the format to DD/MM/YY (European standard)


I have done this using the Format function, but I still have a slight problem
Format(mydate,"dd/mm/yy")

doesnt account for all dates...

for example...
if I enter 31/03/04 this is fine, it will accept it as that

However, if I enter 02/04/04 (todays date - 2nd April 04), it will change it to 04/02/04



Any ideas how I can counter this from happening?

Datagrid & ADO Data Control
Newbie question. I have created a Datagrid control bound to an ADO Data Control using a particular database account and password at design time. How do I use a different account and password at run time? The datagrid control apparently wants to connect first using the design time account/password before I can change the connection using code. In other languages, data sources can be disconnected at design time. I don't see how this is done with an ADO control.

Any help greatly appreciated.

Datagrid: No Ado Data Control
I am trying to populate a datagrid control without having to bind it to an ado data control.

the data, however, is not being displayed. The recordset is retrieving the records from my database but nothing is being displayed in my datagrid.


Here is my code
dim rsS as adodb.recordset
set rsS=new adodb.recordset

rsS.CursorLocation = adUseClient
rsS.CursorType = adOpenStatic
rsS.LockType = adLockOptimistic
rsS.Open "Select School_ID,School_Name,Address,Telephone from School Order by School_Name", connection

Set dgSchools.DataSource = rsS


Do I have to loop through the recordset and set the datafield property of the datagrid columns to the fields in the recordset?

I thought that by setting the datasource property that would be automatically done.

Tesita

Datagrid & ADo Data Control
I have a lookup window that uses datagrid and ADO data control as the data source. After compiling my application that uses this lookup, and deploy it to the target machine, the lookup window on popup does not display data.

However, when i installed VB6 Disk 1 on the target machine and run my application, the lookup window works.

pls how can i figure out the missing file in my application?

thanks

Datagrid,recordset % Ado Data Control
hi, i have a problem with datagrids.

i want to view the result of a query into a datagrid.
i created a recordset(rs) containing the data.
so, i added an ado data control(adodc1) , configured the connection and i wrote:

adodc1. recordsource =rs

after i wrote

set datagrid1.datasource=adodc1

but in the datagrid only the FIRST row of the recordset is shown?
why?

thanks

Clear Data From Datagrid Control?
can anyone help me with this...please..

how do I clear contents of datagrid control? thanks in advance...

How To Display Data In DataGrid Control
please tell me how to display data in DataGrid control, the simplest way to do it. please this is very urgent to me

Inserting Data Using DataGrid Control
On a form, I have a combo box and a data grid.

Based on user's select in the combo box, data grid displays certain data which is supplied by stored procedure.

ComboBox On_LostFocus()
dataGrid.dataSource = rsStoredProc
end ComboBoxSub

Thats how my dataGrid gets it data. I have set the AllowUpdates, AllowInsert, AllowDelete properties of the dataGrid to TRUE. But still there is no additional row on the dataGrid for the user to add data, neither can the user edit or delete.

What is wrong here. Please suggest.

thank you in advance!
Ankeet

DataGrid And ADO Data Control PROBLEMS!
Hi,

I am quite new to database programming in VB.

I have a database that keeps track of different types of accommodations.....and also all the different units that eacy accommodation has.

For example........one accommodation is "Hotel"
and units could be 1, 2, 3, etc

What i want to do is make the program automatically display all the units in a data grid control for the selected type of accommodation.

I've tried doing this...

Adodc2.RecordSource = "SELECT tblUnits.UnitNumber FROM tblUnits WHERE tblUnits.AccTypeID = " & txtAccTypeID.Text

in order to change the data, but this doesnt do anything...the same units are displayd no matter which accommodation type is chosen.

What is the best way to do this?.......any help or advice you can give me would be welcome.

Thanx,
Clint

Data Control & DataGrid Ocx Problem
Hi,
I’m using a VB6 Pro SP4 (the latest). Here’s the problem:
1. I add Data control and DataGrid control (MSDATGRD.OCX) to the form
2. I connect Data control to Biblio.MDB and set RecordSource to one of the tables (Authors)
3. When I try to set DataSource of DataGrid I get the following error

Error Message:
No compatible data source was found for this control. Please add an OLEDB data source such as Data Enviroment or Microsoft ADO Data Control to the form or project.

I also get this message:

Error Message:
Can't bind this control to Data1. Select a different data source (eq - ADODC1, or DataEnviroment1...)

I would really appreciate your help for I need to use data control & bound it to data grid ocx.

Thanks.

Clear Data From Datagrid Control?
I am use to using the MSHFlexGrid and now since the datagrid is a .NET control and the FlexGrid is a COM control I am using the datagrid now. This is a really basic question. I have a datagrid I add data to from an Excel Doc using OleDb. Once it is filled with the file my program allows you to export the data. What I need is this how do I clear the datagrid when I import data from another Excel doc? There is no DataGrid1.Clear method.

Adding Data In DataGrid Control
Hello Friends,
     i am using DataGrid Control and bounded it with database of SQL Server amd adding or updating data from Grid. But the problem is some times it will allow to add or update and sometimes it is not allowing me. I am also selected AddAllowNew property become true.
   so what can i do plz reply me


SPPatel



Edited by - sppatel237 on 3/10/2004 7:52:00 PM

Changing Data In A Datagrid Control
I'm trying to modify data in a DataGrid control through code. I'm able to read what's currently there, but i can't seem to find the property/method that will let me change the data in a certain cell. I'm guessing it MUST be possible, since the user can do it during runtime. Any help would be greatly appreciated.


Thanks

Modifying Data In Datagrid Control ?
hi,
I set up my datagrid control based on a command object in a data environment.
Everything displays nicely, except that I can't edit, add or delete anything.
Does anybody know why ?

thanks,
Maggie

Problem Using An ADO Data Control And An ADO Datagrid In Excel.
Hi,

I'm trying to use an ADO Data Control and link a ADO DataGrid to it to be able to browse/update an Access DB Table. Normal in VB6.0 you setup the ADODC and then just assign the Datasource property of the DataGrid to be the ADODC and it works. In Excel there is no Datasource property in the properties window and when I try to do it through code int the Form Initialise event I get the following error 'Method or Data Member not Found'.

Does anybody have any ideas what I'm doing wrong or how you link a DataGrid to an ADODC in Excel?


Thanks,
Phil.

Datagrid Control Does Not Refresh With Data Environment
Dear Friends,

I am facing a problem with DATAGRID IN VISUAL BASIC 6.00.

I am using a DATAENVIRONMENT with a Connection Object that has OneCommand Object.
The command Object uses the Following Parametric SQL Statement.

SELECT * FROM mondet WHERE cntno=?

Pls note that Mondet is a child table with multiple entries in CNTNOfield - (ACCESS Table)

The Datagrid has the following Data Properties (Thru the PropertiesPage)
The Name of The Data Environment is DE1
the Name of the Command Object is COMMAND1

DATAGRID1.DATASOURCE=DE1
DATAGRID1.DATAMEMBER=COMMAND1



The Datagrid refreshes the first time. But when we run the parametricSQL Statement again to create a new


Recordset, a new Recordset is Created (Checked the Recordcount Propertyof RECORDSET in MSGBOX)


but the DATAGRID is not updated. I have Tried "Rebind", "Refresh"Methods etc. but to no avail.


Infact even the "Clearfields" method does not Work after the FirstRecordset is Created.

Can Anyone of You Help Me out. Pls See that the Datagrid works fine(also Refreshes) with a ADODC Control. But I


Need DATAENVIRONMENT control to be used.



Thanx in Advance

Vinay Vekkot

Import/link XLS To Datagrid Using Data Control
How can I import/link excel file to datagrid using data control,
by coding.



Thank's
Jordan Sparta

Error 0 On DataGrid Linked With Ado Data Control
Does anyone know why I would get error 0 every time I touch the datagrid
during runtime(ie/update, etc)....Which library(s) do I have to reference to
use the datagrid and the ado data control?

Any help would be appreciated!! Thanks
Sonia

Automation Error (440) With ADO Data Control & DataGrid
                    Hello -
                    I am using VB6 against a SQL Server 7 db.

                    This is a very simple program whereby the datagrid is populated
                    by Adodc1  without any VB code.

                    I added a Timer control to refresh the data grid every 10
                    seconds   (Adodc1.Refresh)   This works very well.

                    Problem:  The program runs fine, refreshing the grid
                    periodically....  then after running for several minutes
                   (seems to  always be about 4 - 5  minutes)  get the
                   run-time    Automation   error (error 440)

                    The documentation for Error 440 says -" An error occurred
                    while  executing  a method"

                    Well,  the only method being executed is the .Refresh

                    I can only guess that there is a Timeout problem occurring
                    or  the   SQL Server db  is too busy to respond...?

                    I took the default values for Connection Timeout etc when I created
                    the controls.


                    Has anyone had experience with Automation errors?
                    Thanks for any help.
                    John

Insertion Of Data Using Datagrid Control. VB + SQL Server
Hi,
   I have a problem in inserting the new record's data in DataGrid control.
I have got 2 tables. One table has a foreign key referring to the primary key of other table. Now records exist in primary key table and I am displaying the foreign key table in the Datagrid control. The fields displayed are partial for I dont want user to view all the fields of the table. Some to the fields get updated later as per the programming logic. But when I insert new record corresponding to the left out fields an error is displayed stating cannot insert null value.

Plz suggest a possible solution.

 

Unable To Link DataGrid To Data Control
I am using a Jet (Access) database with ADO. I am trying to display the data from my data control in a data grid. When I try adjusting the 'Data Source' property of the data grid, I get the following message "No compatible data source was found for this control. Please add an OLEDB data source such as the Data Environment or Microsoft ADO Data Control to the form or project." I get this message even though my Data Control is already on the same form.

Copyright © 2005-08 www.BigResource.com, All rights reserved