Re: What's the best way to open a recordset for insert only?



OK, this helps a lot, although I suppose we'll have to trust SQL Server not
to evaluate 0=1 or 1=2 for every existing row in the table.

"Bob Barrows [MVP]" wrote:

Spencer wrote:

So it was a failed experiment, and it looks like I'll have to use the
recordset. But I'm wondering if there's a way to open the recordset
so that I can call AddNew on it, but doesn't query the entire table
first.

Use a disconnected recordset opened using a sql query that includes
"WHERE 1=2"

rs.CursorLocation = adUseClient
m_rsname = "select <fields> from " & m_rsname & " WHERE 1=2"
rs.Open m_rsname, m_conn, , adLockBatchOptimistic, adCmdText
Set rs.ActiveConnection = Nothing
'add your records, then
Set rs.ActiveConnection = m_conn
rs.UpdateBatch

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



.



Relevant Pages

  • Re: Whats the best way to open a recordset for insert only?
    ... So it was a failed experiment, and it looks like I'll have to use the ... But I'm wondering if there's a way to open the recordset ... Use a disconnected recordset opened using a sql query that includes ... Please reply to the newsgroup. ...
    (microsoft.public.data.ado)
  • Re: Whats the best way to open a recordset for insert only?
    ... recordset was disconnected, and then reopen it just before reconnecting ... Spencer wrote: ... Use a disconnected recordset opened using a sql query that includes ... Please reply to the newsgroup. ...
    (microsoft.public.data.ado)
  • Re: Median calculation
    ... Already answered in another newsgroup to which you posted the same question. ... Dim rs As DAO.Recordset ... 'Open a recordset on the table. ... DMedian = rs ...
    (microsoft.public.access.queries)
  • Re: Access sending data to Word VBA Userform
    ... To get assistance on that, it would be best to ask in an Access newsgroup, ... Doug Robbins - Word MVP ... Dim rs As DAO.Recordset ... ' Set the number of Columns = number of Fields in recordset ...
    (microsoft.public.word.vba.userforms)
  • Re: Binding Data to Forms, Textboxes etc.
    ... I intended to post this to the .net forms newsgroup, and yes I may be mixing ... > Windows applications are a very different animal to Access forms. ... The terms 'Row Source' and 'Recordset' are not used ... >> "A bound form means that you have identified a Row Source for your form. ...
    (microsoft.public.access.formscoding)