 |
| 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
|
|
|
|

November 18th, 2003, 04:27 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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()
|
|

November 18th, 2003, 06:10 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

November 19th, 2003, 10:37 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

November 19th, 2003, 10:45 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
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.
|
|

November 19th, 2003, 11:45 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Could you help get me started on this ?
All my sources are making me Dim each datacolumn....
|
|

November 19th, 2003, 12:44 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 
|
|

November 19th, 2003, 12:48 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
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.
|
|

November 19th, 2003, 04:40 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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

|
|

November 19th, 2003, 04:49 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
"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.
|
|

November 19th, 2003, 05:24 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes it is in Window Form.... 
|
|
 |