Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

i'm trying to display a report of information from an access 2000 database in a datagrid in my app. The problem is that it only shows the date and not the specific time, in a column used for showing the date and time a record was made in the database.

 

heres the code

 

Try

objConn.Open()

objDataAdapter.Fill(objDS, "REPORTS")

 

Catch ex As System.Exception

MsgBox(ex.Message)

Finally

If objConn.State = ConnectionState.Open Then

objConn.Close()

End If

End Try

 

objReportsTable.Rows.Clear()

objReportsTable = (objDS.Tables("REPORTS"))

 

'lets the datagrid know that the dateandtime column holds both the data and the time

objReportsTable.Columns("DATEANDTIME").DataType = System.Type.GetType("System.DateTime")

 

Dim objFrmReport As New frmReport()

 

objFrmReport.datReport.DataSource = objReportsTable

 

objFrmReport.Show()

 

the try statement fills up the dataset with the data into a table called REPORTS, i then extract that table into a DataTable type variable, i then assign the datatable as the datasource of the datagrid and display.

 

I found another thread on here with the same problem and the suggestion was to declare the datatype of the column which is what i've implemented in the command on the 4th line from the bottom of the code.

 

Any ideas why this isn't working?

Posted

Hi,

The same problem you are having happened to me las week. The only way that I was able to display the date and time was to fix line 4 of your code:

 

objReportsTable.Columns("DATEANDTIME").DataType = System.Type.GetType("System.DateTime")

to

objReportsTable.Columns("DATEANDTIME").DataType = System.Type.GetType("System.String")

 

this has been the only solution that I have Found so far. I do not know how is going to work whenever you want to edit. but try it and see if it helps.

 

Best of Luck

You're either a one or a zero. Alive or dead.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...