recordset

Closing PreparedStatements

♀尐吖头ヾ 提交于 2019-12-08 16:12:15
问题 Does use of PreparedStatements and ResultSets creates a "new database instance" everytime they are used? Or, whith other words, if I use a PreparedStatement and a ResultSet, should I close them after every use or once I finish? Example: while (...){ p = connection.prepareStatement(...); r = p.executeQuery(); while (r.next()) { .... } } // We close at the end. Or there are any other p and r still opened...? p.close(); r.close(); OR while (...){ p = connection.prepareStatement(...); r = p

MySQL results yesterday, last week, last month and last year

∥☆過路亽.° 提交于 2019-12-08 15:22:41
问题 my datefield ( artists.onlineDate ) is yyy-mm-dd hh:mm:ss right now I got: -- Today SELECT * FROM artists WHERE DATE(artists.onlineDate) = CURDATE() -- Current Week SELECT * FROM artists WHERE WEEK(artists.onlineDate, 3) = WEEK(CURDATE(), 3) -- Current Month SELECT * FROM artists WHERE MONTH(artists.onlineDate) = MONTH(CURDATE()) -- Current Year SELECT * FROM artists WHERE YEAR(artists.onlineDate) = YEAR(CURDATE()) But what I need is exact: Yesterday, Last Week, Last Month, Last Year I try to

Whats the difference between rs.close vs rs = nothing in a RecordSet

≡放荡痞女 提交于 2019-12-08 14:35:31
问题 I often find it confusing as to when it is appropriate to use: rs.Close opposed to Set rs = Nothing I can understand needing to close a connection to a source, but should I be using both when the variable falls out of scope? Can I just set the variable to Nothing in order to skip the step of Closing the connection? Would this be considered a bad practice? 回答1: By using the "Close" method you are closing the connection to the database but is still in the memory where you can open again using

How do I export 2 queries to a single worksheet in excel from access

房东的猫 提交于 2019-12-08 10:23:38
问题 I'm using TransferSpreadsheet to export a query from access to excel and it works fine. DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryName", "test1.xls", True Now I've got another query and I want to add the data from this query to the same worksheet. How can I do this? 回答1: For my first query I use DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "qryNameFirst", "test1.xlsx", True, "MyWorksheetName" For the second query I put it in a recordset Dim rstName

Convert PDO recordset to JSON in PHP

六眼飞鱼酱① 提交于 2019-12-08 06:24:31
问题 Im using PHP and I need a way to convert an entire recordset to a JSON string. While searching Stack Overflow I found this solution that works: function recordSetToJson($mysql_result) { $rs = array(); while($rs[] = mysql_fetch_assoc($mysql_result)) { // you don´t really need to do anything here. } return json_encode($rs); } The problem with this code is that I found that the function mysql_fetch_assoc() is deprecated in PHP 5.5.0. Another thing is that im using PDO to connect to my database.

Insert Complete RecordSet to another table in other database MS Access

独自空忆成欢 提交于 2019-12-08 05:43:38
问题 I have 2 Tables with same colums in two diferent files. One file "Base PT.accdb" where i want to insert all the Recordset from the other file "Sanchez_Mar.mdb". Both tables have 7 Columns with the same name. I had a lot of problems using "System.Data.OleDb.OleDbConnection" so i decided to use RecordSets. At the moment i'm using loop to insert all, but there is a lot of data so it take quite long. It's posible to insert all the recordset to the other database ? this is the part of my code i

General Java Method that Queries DB and Returns Results in Json Format

我们两清 提交于 2019-12-07 20:21:40
问题 What I'm looking for seems pretty straight forward to me, but my googles have failed. I want a method that allows me to run any query and get the results in json format. The trick is I don't want the results to need java objects as part of the process (DTOs, VOs, etc). Any quick/easy/clean ways of doing this? 回答1: Jackson has some pretty nice ways of doing it. There's some examples in this answer that should work wonders for you. Alternatively, if Jackson isn't available to you, you could

How to access values in a recordset

倾然丶 夕夏残阳落幕 提交于 2019-12-07 07:23:40
问题 Take for example this code: sSQL = "select CtyMarket from Market where Country = '" & Country.Value & "'" Set rec = CurrentDb.OpenRecordset(sSQL) This statement can return more than one value. How can I access those values? 回答1: well, in order to get all the values you could browse both fields and records in your recordset. It could look like that: 'You'll need to declare a new variable Dim i as long If rec.EOF and rec.BOF then Else do while not rec.EOF for i = 0 to rec.fields.count - 1 debug

Insert Complete RecordSet to another table in other database MS Access

人走茶凉 提交于 2019-12-06 21:22:31
I have 2 Tables with same colums in two diferent files. One file "Base PT.accdb" where i want to insert all the Recordset from the other file "Sanchez_Mar.mdb". Both tables have 7 Columns with the same name. I had a lot of problems using "System.Data.OleDb.OleDbConnection" so i decided to use RecordSets. At the moment i'm using loop to insert all, but there is a lot of data so it take quite long. It's posible to insert all the recordset to the other database ? this is the part of my code i need help: Sub Copiar_BasePT2(RutaPT As String) Dim Cant as Long Dim db As Database Dim dbBase_PT As

General Java Method that Queries DB and Returns Results in Json Format

旧街凉风 提交于 2019-12-06 09:31:38
What I'm looking for seems pretty straight forward to me, but my googles have failed. I want a method that allows me to run any query and get the results in json format. The trick is I don't want the results to need java objects as part of the process (DTOs, VOs, etc). Any quick/easy/clean ways of doing this? DominicEU Jackson has some pretty nice ways of doing it. There's some examples in this answer that should work wonders for you. Alternatively, if Jackson isn't available to you, you could check out this I accepted DominicEU's answer because it provided me with what I needed to get things