Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 18th, 2003, 04:27 PM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataGrid Information

Dear Users,
(Below is my code to view datagrid1)
I have a datagrid which I use to return Dates and times from Access Database. 1) My dates come back a long Dates, but all I would like is one column for times. 2) How do I make it a read only Datagrid without the '*' to confuse users 3) How do I make it updated able, only by the user who entered the information.'I can do the query to make sure the users names match, but how do I leave the connection open ?'

Dim conStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\DATA\ACCESS\13FloorEquipment.mdb"
            Dim strSQL As String = "SELECT [ItemName], [StartDate],[EndDate],[NTID] FROM(Requests) "
            strSQL = strSQL & "WHERE (([ItemName]= '" & nItem & "')"
            strSQL = strSQL & "AND (([StartDate])"
            strSQL = strSQL & "BETWEEN #" & kStart & " 12:00:00 AM #"
            strSQL = strSQL & "AND #" & kStop & " 11:59:59 PM #));"
            'MsgBox(strSQL)

            Dim conn As OleDbConnection = New OleDbConnection(conStr)
            conn.Open()
            Dim da As OleDbDataAdapter = New OleDbDataAdapter(strSQL, conn)

            Dim ds As DataSet = New DataSet()
            da.Fill(ds, "Requests")
            Dim dv As DataView = ds.Tables("Requests").DefaultView
            DataGrid1.DataSource = dv

            conn.Close()
 
Old November 18th, 2003, 06:10 PM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear user how do I get this code to allow me to update my database thru this Datagrid??

Dim COmpare As String
        Dim NTID As String
        Dim Dtemp As Date
        Dim FTemp As Date
        Dim z As Long

        NTID = txtNTID.Text

        Dim Direct As String = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\DATA\ACCESS\13FloorEquipment.mdb"
        Dim strSQL As String = "SELECT [ItemName], [StartDate],[EndDate],[NTID] FROM(Requests) "
        strSQL = strSQL & "Where(([NTID]='" & NTID & "'));"

        Dim conn As OleDbConnection = New OleDbConnection(Direct)
        conn.Open()
        Dim Xa As OleDbDataAdapter = New OleDbDataAdapter(strSQL, conn)

        Dim Xs As DataSet = New DataSet()
        Xa.Fill(Xs, "Requests")
        Dim Xv As DataView = Xs.Tables("Requests").DefaultView
        DataGrid1.DataSource = Xv

        conn.Close()
        'Next
 
Old November 19th, 2003, 10:37 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The code I have shown only returns information in the database I query, but I would like to click on a row and delete the whole row. How is this possible?

Thank you
 
Old November 19th, 2003, 10:45 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The datagrid class has a delete command event for when you click on a delete button in a particular row. You can have that handler call the database to delete a row based on the key field(s) in your database. It looks like NTID is a key field, so you could make that delete call using the value from the datagrid item passed into the delete handler.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 19th, 2003, 11:45 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Could you help get me started on this ?

All my sources are making me Dim each datacolumn....
 
Old November 19th, 2003, 12:44 PM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The Datagrid I have is being used to return several things. 1) View information from Database 2) would like to 'Delete' a highlit row, but only but the NTID. Can someone help
 
Old November 19th, 2003, 12:48 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What kind of project is this? The DataGrid object is different between a windows forms application and a ASP.Net webforms application.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 19th, 2003, 04:40 PM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This Form is being done in VS.net, and use OleDb connection to link to my Access Database which is on our company network. Access Dbase is not on a SQL Server, so I have to use OleDb Connector...

Thank you
 
Old November 19th, 2003, 04:49 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

"being done in VS.Net" doesn't help.
Is this a windows form or an ASP.Net web form?

I am familiar with datagrids in web forms, but not in windows forms so I might not be able to provide the answer.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 19th, 2003, 05:24 PM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes it is in Window Form....





Similar Threads
Thread Thread Starter Forum Replies Last Post
Information on CSS Bourke36 CSS Cascading Style Sheets 0 July 19th, 2008 03:59 AM
further information dhoward Crystal Reports 0 February 21st, 2008 03:57 PM
information about iis piyush_patel ASP.NET 1.x and 2.0 Application Design 1 September 28th, 2007 10:59 AM
Information on C# student_help C# 1 December 16th, 2005 07:34 PM
DataGrid Information KennethMungwira ADO.NET 6 September 24th, 2004 10:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.