Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Database
MS Access
How to get a DataTable using parameters?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="tombihn, post: 137834, member: 32416"] I saw another post where jmcilhinney graciously helped another programmer with fixing a coding issue and suggested using parameters. The link to his blog in his post was very helpful and I'm trying to change my code in to use parameters instead of the previous method. In my previous method, I concatenated the sql query and included the dtBeginDate variable in the query. It is querying an Access database. The method I was using involved creating a dataadapter object from this query then filling my DataSet, ds, with this table called "WorkOrders". I never do an update with this data. The purpose is only to get the data from the database. My question is how can I use a command object to pass a parameter and add a table to the dataset. Below is the code I have so far, but I'm stuck trying to figure out where to go from here. [XCODE=vb.net] Dim dtBeginDate As Date = Today().Date.AddYears(-1) Dim SQL_RecentWorkOrders As String = "SELECT workorders.CustID as WO_CustID, " + "workorders.[Work Order Number] as WO_Number, " + "workorders.Date as WO_Date, " + "customer.lastname as CustLastName, " + "workorders.OperLast, " + "workorders.OperFirst, " + "workorders.FieldID as WO_Desc, " + "workorders.Acres, " + "workorders.Grid " + "FROM workorders " + "INNER JOIN customer " + "ON workorders.custid = customer.custid " + "WHERE workorders.Date> @BeginDate ORDER BY workorders.[Work Order Number] DESC" ' Old code: daAccess = New OleDbDataAdapter(SQL_RecentWorkOrders, cnAccess) ' Old code: daAccess.Fill(ds, "WorkOrders") Dim cmd As New OleDbCommand(SQL_RecentWorkOrders) cmd.Parameters.AddWithValue("@BeginDAte", dtBeginDate) cmd.ExecuteNonQuery() ds.Tables.Add(.... [/XCODE] How do I get a table into my DataSet at this point? [/QUOTE]
Insert quotes…
Verification
Post reply
Database
MS Access
How to get a DataTable using parameters?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom