Search Results

Search found 176 results on 8 pages for 'adodb'.

Page 3/8 | < Previous Page | 1 2 3 4 5 6 7 8  | Next Page >

  • Connection Pooling is Busted

    - by MightyZot
    A few weeks ago we started getting complaints about performance in an application that has performed very well for many years.  The application is a n-tier application that uses ADODB with the SQLOLEDB provider to talk to a SQL Server database.  Our object model is written in such a way that each public method validates security before performing requested actions, so there is a significant number of queries executed to get information about file cabinets, retrieve images, create workflows, etc.  (PaperWise is a document management and workflow system.)  A common factor for these customers is that they have remote offices connected via MPLS networks. Naturally, the first thing we looked at was the query performance in SQL Profiler.  All of the queries were executing within expected timeframes, most of them were so fast that the duration in SQL Profiler was zero.  After getting nowhere with SQL Profiler, the situation was escalated to me.  I decided to take a peek with Process Monitor.  Procmon revealed some “gaps” in the TCP/IP traffic.  There were notable delays between send and receive pairs.  The send and receive pairs themselves were quite snappy, but quite often there was a notable delay between a receive and the next send.  You might expect some delay because, presumably, the application is doing some thinking in-between the pairs.  But, comparing the procmon data at the remote locations with the procmon data for workstations on the local network showed that the remote workstations were significantly delayed.  Procmon also showed a high number of disconnects. Wireshark traces showed that connections to the database were taking between 75ms and 150ms.  Not only that, but connections to a file share containing images were taking 2 seconds!  So, I asked about a trust.  Sure enough there was a trust between two domains and the file share was on the second domain.  Joining a remote workstation to the domain hosting the share containing images alleviated the time delay in accessing the file share.  Removing the trust had no affect on the connections to the database. Microsoft Network Monitor includes filters that parse TDS packets.  TDS is the protocol that SQL Server uses to communicate.  There is a certificate exchange and some SSL that occurs during authentication.  All of this was evident in the network traffic.  After staring at the network traffic for a while, and examining packets, I decided to call it a night.  On the way home that night, something about the traffic kept nagging at me.  Then it dawned on me…at the beginning of the dance of packets between the client and the server all was well.  Connection pooling was working and I could see multiple queries getting executed on the same connection and ethereal port.  After a particular query, connecting to two different servers, I noticed that ADODB and SQLOLEDB started making repeated connections to the database on different ethereal ports.  SQL Server would execute a single query and respond on a port, then open a new port and execute the next query.  Connection pooling appeared to be broken. The next morning I wrote a test to confirm my hypothesis.  Turns out that the sequence causing the connection nastiness goes something like this: Make a connection to the database. Open a result set that returns enough records to require multiple roundtrips to the server. For each result, query for some other data in the database (this will open a new implicit connection.) Close the inner result set and repeat for every item in the original result set. Close the original connection. Provided that the first result set returns enough data to require multiple roundtrips to the server, ADODB and SQLOLEDB will start making new connections to the database for each query executed in the loop.  Originally, I thought this might be due to Microsoft’s denial of service (ddos) attack protection.  After turning those features off to no avail, I eventually thought to switch my queries to client-side cursors instead of server-side cursors.  Server-side cursors are the default, by the way.  Voila!  After switching to client-side cursors, the disconnects were gone and the above sequence yielded two connections as expected. While the real problem is the amount of time it takes to make connections over these MPLS networks (100ms on average), switching to client-side cursors made the problem go away.  Believe it or not, this is actually documented by Microsoft, and rather difficult to find.  (At least it was while we were trying to troubleshoot the problem!)  So, if you’re noticing performance issues on slower networks, or networks with slower switching, take a look at the traffic in a tool like Microsoft Network Monitor.  If you notice a high number of disconnects, and you’re using fire-hose or server-side cursors, then try switching to client-side cursors and you may see the problem go away. Most likely, Microsoft believes this to be appropriate behavior, because ADODB can’t guarantee that all of the data has been retrieved when you execute the inner queries.  I’m not convinced, though, because the problem remains even after replacing all of the implicit connections with explicit connections and closing those connections in-between each of the inner queries.  In that case, there doesn’t seem to be a reason why ADODB can’t use a single connection from the connection pool to make the additional queries, bringing the total number of connections to two.  Instead ADO appears to make an assumption about the state of the connection. I’ve reported the behavior to Microsoft and am awaiting to hear from the appropriate team, so that I can demonstrate the problem.  Maybe they can explain to us why this is appropriate behavior.  :)

    Read the article

  • Forms bound to updateable ADO recordsets are not updateable when the source includes a JOIN

    - by Art
    I'm developing an application in Access 2007. It uses an .accdb front end connecting to an SQL Server 2005 backend. I use forms that are bound to ADO recordsets at runtime. For the sake of efficiency, the recordsets usually contain only one record, and are queried out on the server: Public Sub SetUpFormRecordset(cn As ADODB.Connection, rstIn As ADODB.Recordset, rstSource As String) Dim cmd As ADODB.Command Dim I As Long Set cmd = New ADODB.Command cn.Errors.Clear ' Recordsets based on command object Execute method are Read Only! With cmd Set .ActiveConnection = cn .CommandType = adCmdText .CommandText = rstSource End With With rstIn .CursorType = adOpenKeyset .LockType = adLockPessimistic 'Check the locktype after opening; optimistic locking is worthless on a bound End With ' form, and ADO might open optimistically without firing an error! rstIn.Open cmd, , adOpenKeyset, adLockPessimistic 'This should run the query on the server and return an updatable recordset With cn If .Errors.Count <> 0 Then For Each errADO In .Errors Call HandleADOErrors(.Errors(I)) I = I + 1 Next errADO End If End With End Sub rstSource (the string containg the TSQL on which the recordset is based) is assembled by the calling routine, in this case from the Open event of the form being bound: Private Sub Form_Open(Cancel As Integer) Dim rst As ADODB.Recordset Dim strSource As String, DefaultSource as String Dim lngID As Long lngID = Forms!MyParent.CurrentID strSource = "SELECT TOP (100) PERCENT dbo.Customers.CustomerID, dbo.Customers.LegacyID, dbo.Customers.Active, dbo.Customers.TypeID, dbo.Customers.Category, " & _ "dbo.Customers.Source, dbo.Customers.CustomerName, dbo.Customers.CustAddrID, dbo.Customers.Email, dbo.Customers.TaxExempt, dbo.Customers.SalesTaxCode, " & _ "dbo.Customers.SalesTax2Code, dbo.Customers.CreditLimit, dbo.Customers.CreationDate, dbo.Customers.FirstOrder, dbo.Customers.LastOrder, " & _ "dbo.Customers.nOrders, dbo.Customers.Concurrency, dbo.Customers.LegacyLN, dbo.Addresses.AddrType, dbo.Addresses.AddrLine1, dbo.Addresses.AddrLine2, " & _ "dbo.Addresses.City, dbo.Addresses.State, dbo.Addresses.Country, dbo.Addresses.PostalCode, dbo.Addresses.PhoneLandline, dbo.Addresses.Concurrency " & _ "FROM dbo.Customers INNER JOIN " & _ "dbo.Addresses ON dbo.Customers.CustAddrID = dbo.Addresses.AddrID " strSource = strSource & "WHERE dbo.Customers.CustomerID= " & lngID With Me 'Default is Set up for editing one record If Not Nz(.RecordSource, vbNullString) = vbNullString Then If .Dirty Then .Dirty = False 'Save any changes on the form .RecordSource = vbNullString End If If rst Is Nothing Then 'Might not be first time through DefaultSource = .RecordSource Else rst.Close Set rst = Nothing End If End With Set rst = New ADODB.Recordset Call setupformrecordset(dbconn, rst, strSource) 'dbconn is a global variable With Me Set .Recordset = rst End With End Sub The recordset that is returned from setupformrecordset is fully updateable, and its .Supports property shows this. It can be edited and updated in code. The entire form, however, is read only, even though it's .AllowEdits and .AllowAdditions properties are both true. Even the fields from the right hand side (the 'many' side) cannot be edited. Removing the INNER JOIN clause from the TSQL (restricting strSource to one table) makes the form fully editable. I've verified that the TSQL includes priimary key fields from both tables, and each table includes a timestamp field for concurrency. I tried changing the .CursorType and .CursorLocation properties of the recordset to no avail. What am I doing wrong?

    Read the article

  • Automation Error upon running VBA script in Excel

    - by brohjoe
    Hi guys, I'm getting an Automation error upon running VBA code in Excel 2007. I'm attempting to connect to a remote SQL Server DB and load data to from Excel to SQL Server. The error I get is, "Run-time error '-2147217843(80040e4d)': Automation error". I checked out the MSDN site and it suggested that this may be due to a bug associated with the sqloledb provider and one way to mitigate this is to use ODBC. Well I changed the connection string to reflect ODBC provider and associated parameters and I'm still getting the same error. Here is the code with ODBC as the provider: Dim cnt As ADODB.Connection Dim rst As ADODB.Recordset Dim stSQL As String Dim wbBook As Workbook Dim wsSheet As Worksheet Dim rnStart As Range Public Sub loadData() 'This was set up using Microsoft ActiveX Data Components version 6.0. 'Create ADODB connection object, open connection and construct the connection string object. Set cnt = New ADODB.Connection cnt.ConnectionString = _ "Driver={SQL Server}; Server=onlineSQLServer2010.foo.com; Database=fooDB Uid=logonalready;Pwd='helpmeOB1';" cnt.Open On Error GoTo ErrorHandler 'Open Excel and run query to export data to SQL Server. strSQL = "SELECT * INTO SalesOrders FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0', & _ "'Data Source=C:\Database.xlsx; Extended Properties=Excel 12.0')...[SalesOrders$]" cnt.Execute (strSQL) 'Error handling. ErrorExit: 'Reclaim memory from the connection objects Set rst = Nothing Set cnt = Nothing Exit Sub ErrorHandler: MsgBox Err.Description, vbCritical Resume ErrorExit 'clean up and reclaim memory resources. cnt.Close If CBool(cnt.State And adStateOpen) Then Set rst = Nothing Set cnt = Nothing End If End Sub

    Read the article

  • excel:mysql: rs.Update crashes

    - by every_answer_gets_a_point
    i am connecting to mysql from excel and updating a table. as soon as i get to .update (rs.update) excel crashes. am i doing something wrong? Option Explicit Dim oConn As ADODB.Connection Private Sub ConnectDB() Set oConn = New ADODB.Connection oConn.Open "DRIVER={MySQL ODBC 5.1 Driver};" & _ "SERVER=localhost;" & _ "DATABASE=employees;" & _ "USER=root;" & _ "PASSWORD=pas;" & _ "Option=3" End Sub Function esc(txt As String) esc = Trim(Replace(txt, "'", "\'")) End Function Private Sub InsertData() Dim dpath, atime, rtime, lcalib, aname, rname, bstate, instrument As String Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset ConnectDB With wsBooks rs.Open "batchinfo", oConn, adOpenKeyset, adLockOptimistic, adCmdTable Worksheets.Item("Report 1").Select dpath = Trim(Range("B2").Text) atime = Trim(Range("B3").Text) rtime = Trim(Range("B4").Text) lcalib = Trim(Range("B5").Text) aname = Trim(Range("B6").Text) rname = Trim(Range("B7").Text) bstate = Trim(Range("B8").Text) ' instrument = GetInstrFromXML(wbBook.FullName) With rs .AddNew ' create a new record ' add values to each field in the record .Fields("datapath") = dpath .Fields("analysistime") = atime .Fields("reporttime") = rtime .Fields("lastcalib") = lcalib .Fields("analystname") = aname .Fields("reportname") = rname .Fields("batchstate") = bstate ' .Fields("instrument") = "NA" .Update ' stores the new record End With ' get the last id Set rs = oConn.Execute("SELECT @@identity", , adCmdText) 'MsgBox capture_id rs.Close Set rs = Nothing End With End Sub

    Read the article

  • Automation Error when exporting Excel data to SQL Server

    - by brohjoe
    I'm getting an Automation error upon running VBA code in Excel 2007. I'm attempting to connect to a remote SQL Server DB and load data to from Excel to SQL Server. The error I get is, "Run-time error '-2147217843(80040e4d)': Automation error". I checked out the MSDN site and it suggested that this may be due to a bug associated with the sqloledb provider and one way to mitigate this is to use ODBC. Well I changed the connection string to reflect ODBC provider and associated parameters and I'm still getting the same error. Here is the code with ODBC as the provider: Dim cnt As ADODB.Connection Dim rst As ADODB.Recordset Dim stSQL As String Dim wbBook As Workbook Dim wsSheet As Worksheet Dim rnStart As Range Public Sub loadData() 'This was set up using Microsoft ActiveX Data Components version 6.0. 'Create ADODB connection object, open connection and construct the connection string object. Set cnt = New ADODB.Connection cnt.ConnectionString = "Driver={SQL Server}; Server=onlineSQLServer2010.foo.com; Database=fooDB;Uid=logonalready;Pwd='helpmeOB1';" cnt.Open On Error GoTo ErrorHandler 'Open Excel and run query to export data to SQL Server. strSQL = "SELECT * INTO SalesOrders FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0'," & _ "'Data Source=C:\Database.xlsx; Extended Properties=Excel 12.0')...[SalesOrders$]" cnt.Execute (strSQL) 'Error handling. ErrorExit: 'Reclaim memory from the connection objects Set rst = Nothing Set cnt = Nothing Exit Sub ErrorHandler: MsgBox Err.Description, vbCritical Resume ErrorExit 'clean up and reclaim memory resources. If CBool(cnt.State And adStateOpen) Then Set rst = Nothing Set cnt = Nothing cnt.Close End If End Sub

    Read the article

  • Excel VBA SQL Import

    - by user307655
    Hi All, I have the following code which imports data from a spreadsheet to SQL directly from Excel VBA. The code works great. However I am wondering if somebody can help me modify the code to: 1) Check if data from column A already exists in the SQL Table 2) If exists, then only update rather than import as a new role 3) if does not exist then import as a new role. Thanks again for your help Sub SQLIM() ' Send data to SQL Server ' This code loads data from an Excel Worksheet to an SQL Server Table ' Data should start in column A and should be in the same order as the server table ' Autonumber fields should NOT be included' ' FOR THIS CODE TO WORK ' In VBE you need to go Tools References and check Microsoft Active X Data Objects 2.x library Dim Cn As ADODB.Connection Dim ServerName As String Dim DatabaseName As String Dim TableName As String Dim UserID As String Dim Password As String Dim rs As ADODB.Recordset Dim RowCounter As Long Dim ColCounter As Integer Dim NoOfFields As Integer Dim StartRow As Long Dim EndRow As Long Dim shtSheetToWork As Worksheet Set shtSheetToWork = ActiveWorkbook.Worksheets("Sheet1") Set rs = New ADODB.Recordset ServerName = "WIN764X\sqlexpress" ' Enter your server name here DatabaseName = "two28it" ' Enter your database name here TableName = "COS" ' Enter your Table name here UserID = "" ' Enter your user ID here ' (Leave ID and Password blank if using windows Authentification") Password = "" ' Enter your password here NoOfFields = 7 ' Enter number of fields to update (eg. columns in your worksheet) StartRow = 2 ' Enter row in sheet to start reading records EndRow = shtSheetToWork.Cells(Rows.Count, 1).End(xlUp).Row ' Enter row of last record in sheet ' CHANGES ' Dim shtSheetToWork As Worksheet ' Set shtSheetToWork = ActiveWorkbook.Worksheets("Sheet1") '** Set Cn = New ADODB.Connection Cn.Open "Driver={SQL Server};Server=" & ServerName & ";Database=" & DatabaseName & _ ";Uid=" & UserID & ";Pwd=" & Password & ";" rs.Open TableName, Cn, adOpenKeyset, adLockOptimistic For RowCounter = StartRow To EndRow rs.AddNew For ColCounter = 1 To NoOfFields rs(ColCounter - 1) = shtSheetToWork.Cells(RowCounter, ColCounter) Next ColCounter Next RowCounter rs.UpdateBatch ' Tidy up rs.Close Set rs = Nothing Cn.Close Set Cn = Nothing End Sub

    Read the article

  • Getting "[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'Microsoft.'

    - by brohjoe
    Hi Experts, I'm getting an error, "[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'Microsoft.' Here is the code: Dim conn As ADODB.Connection Dim rst As ADODB.Recordset Dim stSQL As String Public Sub loadData() 'This was set up using Microsoft ActiveX Data Components version 6.0. 'Create ADODB connection object, open connection and construct the connection string object which is the DSN name. Set conn = New ADODB.Connection conn.ConnectionString = "sql_server" conn.Open 'conn.Execute (strSQL) On Error GoTo ErrorHandler 'Open Excel and run query to export data to SQL Server. strSQL = "SELECT * INTO SalesOrders FROM OPENDATASOURCE(Microsoft.ACE.OLEDB.12.0;" & _ "Data Source=C:\Workbook.xlsx;" & _ "Extended Properties=Excel 12.0; [Sales Orders])" conn.Execute (strSQL) 'Error handling. ErrorExit: 'Reclaim memory from the cntection objects Set rst = Nothing Set conn = Nothing Exit Sub ErrorHandler: MsgBox Err.Description, vbCritical Resume ErrorExit 'clean up and reclaim memory resources. conn.Close If CBool(cnt.State And adStateOpen) Then Set rst = Nothing Set conn = Nothing End If End Sub

    Read the article

  • Requested operation requires an OLE DB Session object... - Connecting Excel to SQL server via ADO

    - by Frank V
    I'm attempting to take Excel 2003 and connect it to SQL Server 2000 to run a few dynamicly generated SQL Queries which ultimately filling certain cells. I'm attempting to do this via VBA via ADO (I've tried 2.8 to 2.0) but I'm getting an error while setting the ActiveConnection variable which is inside the ADODB.Connection object. I need to resolve this pretty quick... Requested operation requires an OLE DB Session object, which is not supported by the current provider. I'm honestly not sure what this error means and right now I don't care. How can get this connection to succeed so that I can run my queries? Here is my VB code: Dim SQL As String, RetValue As String SQL = " select top 1 DateTimeValue from SrcTable where x='value' " 'Not the real SQL RetValue = "" Dim RS As ADODB.Recordset Dim Con As New ADODB.Connection Dim Cmd As New ADODB.Command Con.ConnectionString = "Provider=sqloledb;DRIVER=SQL Server;Data Source=Server\Instance;Initial Catalog=MyDB_DC;User Id=<UserName>;Password=<Password>;" Con.CommandTimeout = (60 * 30) Set Cmd.ActiveConnection = Con ''Error occurs here. ' I'm not sure if the rest is right. I've just coded it. Can't get past the line above. Cmd.CommandText = SQL Cmd.CommandType = adCmdText Con.Open Set RS = Cmd.Execute() If Not RS.EOF Then RetValue = RS(0).Value Debug.Print "RetValue is: " & RetValue End If Con.Close I imagine something is wrong with the connection string but I've tried over a dozen variations. Now I'm just shooting in the dark.... Note/Update: To make matters more confusing, if I Google for the error quote above, I get a lot of hits back but nothing seems relevant or I'm not sure what information is relevant.... I've got the VBA code in "Sheet1" under "Microsoft Excel Objects." I've done this before but usually put things in a module. Could this make a difference?

    Read the article

  • How to execute stored procedure from Access using linked tables

    - by webworm
    I have an Access 2003 database that connects to a SQL Server 2008 box via ODBC. The tables from SQL Server are connected as linked tables in Access. I have a stored procedure on the SQL Server that I am trying to execute via ADO code. The problem I have is that Access cannot seem to find the procedure. What do I have to do within Access to be able to execute this stored procedure? Some facts ... The stored procedure in question accepts one parameter which is an integer. The stored procedure returns a recordset which I am hoping to use as the datasource for a ListBox. Here is my ADO code in Access ... Private Sub LoadUserCaseList(userID As Integer) Dim cmd As ADODB.Command Set cmd = New ADODB.Command cmd.ActiveConnection = CurrentProject.Connection cmd.CommandType = adCmdStoredProc cmd.CommandText = "uspGetUserCaseSummaryList" Dim par As New ADODB.Parameter Set par = cmd.CreateParameter("userID", adInteger) cmd.Parameters.Append par cmd.Parameters("userID") = userID Dim rs As ADODB.Recordset Set rs = cmd.Execute() lstUserCases.Recordset = rs End Sub The error I get is "the microsoft jet database engine cannot find the input table or query "uspGetUserCaseSummaryList".

    Read the article

  • query sql database for specific value in vb.net

    - by user2952298
    I am trying to convert VBA code to vb.net, im having trouble trying to search the database for a specific value around an if statement. any suggestions would be greatly appriciated. thedatabase is called confirmation, type is the column and email is the value im looking for. could datasets work? Function SendEmails() As Boolean Dim objOutlook As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment Dim intResponse As Integer Dim confirmation As New ADODB.Recordset Dim details As New ADODB.Recordset On Error GoTo Err_Execute Dim MyConnObj As New ADODB.Connection Dim cn As New ADODB.Connection() MyConnObj.Open( _ "Provider = sqloledb;" & _ "Server=myserver;" & _ "Database=Email_Text;" & _ "User Id=bla;" & _ "Password=bla;") confirmation.Open("Confirmation_list", MyConnObj) details.Open("MessagesToSend", MyConnObj) If details.EOF = False Then confirmation.MoveFirst() Do While Not confirmation.EOF If confirmation![Type] = "Email" Then ' Create the Outlook session. objOutlook = CreateObject("Outlook.Application") ' Create the message. End IF

    Read the article

  • connecting to mysql from excel: ODBC driver does not support the requested properties.

    - by every_answer_gets_a_point
    i am trying to add data to mysql from excel. i am getting the above error on this line: rs.Open strSQL, oConn, adOpenDynamic, adLockOptimistic here is my code: Dim oConn As ADODB.Connection Private Sub ConnectDB() Set oConn = New ADODB.Connection oConn.Open "DRIVER={MySQL ODBC 5.1 Driver};" & _ "SERVER=localhost;" & _ "DATABASE=employees;" & _ "USER=root;" & _ "PASSWORD=some_pass;" & _ "Option=3" End Sub Function esc(txt As String) esc = Trim(Replace(txt, "'", "\'")) End Function Private Sub InsertData() Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset ConnectDB With wsBooks For rowCursor = 2 To 11 strSQL = "INSERT INTO tutorial (author, title, price) " & _ "VALUES ('" & esc(.Cells(rowCursor, 1)) & "', " & _ "'" & esc(.Cells(rowCursor, 2)) & "', " & _ esc(.Cells(rowCursor, 3)) & ")" rs.Open strSQL, oConn, adOpenDynamic, adLockOptimistic Next End With End Sub whats wrong with rs.Open strSQL, oConn, adOpenDynamic, adLockOptimistic ? why am i getting the odbc error?

    Read the article

  • excel:mysql: rs.Update not working

    - by every_answer_gets_a_point
    i am updating a table using an ODBC connection from excel to mysql unfortunately the only column that gets updated is this one: .Fields("instrument") = "NA" where i am assigning variables to .Fields, it is putting NULL values!! what is going on here? here's the code Option Explicit Dim oConn As ADODB.Connection Private Sub ConnectDB() Set oConn = New ADODB.Connection oConn.Open "DRIVER={MySQL ODBC 5.1 Driver};" & _ "SERVER=localhost;" & _ "DATABASE=employees;" & _ "USER=root;" & _ "PASSWORD=pas;" & _ "Option=3" End Sub Function esc(txt As String) esc = Trim(Replace(txt, "'", "\'")) End Function Private Sub InsertData() Dim dpath, atime, rtime, lcalib, aname, rname, bstate, instrument As String Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset ConnectDB With wsBooks rs.Open "batchinfo", oConn, adOpenKeyset, adLockOptimistic, adCmdTable Worksheets.Item("Report 1").Select dpath = Trim(Range("B2").Text) atime = Trim(Range("B3").Text) rtime = Trim(Range("B4").Text) lcalib = Trim(Range("B5").Text) aname = Trim(Range("B6").Text) rname = Trim(Range("B7").Text) bstate = Trim(Range("B8").Text) ' instrument = GetInstrFromXML(wbBook.FullName) With rs .AddNew ' create a new record ' add values to each field in the record .Fields("datapath") = dpath .Fields("analysistime") = atime .Fields("reporttime") = rtime .Fields("lastcalib") = lcalib .Fields("analystname") = aname .Fields("reportname") = rname .Fields("batchstate") = bstate .Fields("instrument") = "NA" .Update ' stores the new record End With ' get the last id Set rs = oConn.Execute("SELECT @@identity", , adCmdText) 'MsgBox capture_id rs.Close Set rs = Nothing End With End Sub

    Read the article

  • Vb.net on running shows updation exception

    - by harun123
    I've a website in vb.net. While running the website i get the following error: "Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype." My DB connection.inc file looks as follows: <%@ Import namespace="ADODB" % Dim strDataSource As String Dim cnnCRM As ADODB.Connection <% cnnCRM = New ADODB.Connection strDataSource = Server.MapPath(".") & "/database/crm.mdb" 'strDataSource="c://crm/crm.mdb" cnnCRM.Open("PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & strDataSource) % I've tried giving the record set object all the properties it required. Still the same error. Can anybody tell me how i can get rid of this error?.....

    Read the article

  • ADO "Unspecified Error" instead of actual error when fetching server side cursor

    - by Dan
    This relates to my recent question: http://stackoverflow.com/questions/2835663/force-oracle-error-on-fetch I am now able to reproduce a scenario where using ADO with the Oracle OLEDB Provider, I can force an error such as ORA-01722: invalid number to occur on calling Recordset.MoveNext However, this is not the error that is returned to the application. Instead, the application sees Provider error '80004005' Unspecified error. How can I get the application to see the real error from the database? This is with Oracle 10g (client and server), if it matters. Sample code is roughly as follows: Dim con As New ADODB.Connection Dim cmd As New ADODB.Command Dim rs As ADODB.Recordset con.ConnectionString = "Provider=OraOLEDB.ORACLE;Data Source=xxx;User Id=yyy;Password=zzz" con.CursorLocation = adUseServer con.Open Set cmd.ActiveConnection = con cmd.CommandText = "select * from table(ret_err)" cmd.Prepared = True Set rs = cmd.Execute While Not rs.EOF rs.MoveNext Wend

    Read the article

  • Vba to Access record Insert Issue

    - by raam
    I want to insert Values to access table by using VBA control is there is any simple way to do this. i try this code but it does not work properly if i run this code it give the error 'variable not set' can anyone help me. thanks in advance Private Sub CommandButton1_Click() Dim cn As ADODB.Connection Dim strSql As String Dim lngKt As Long Dim dbConnectStr As String Dim Catalog As Object Dim cnt As ADODB.Connection Dim dbPath As String Dim myRecordset As New ADODB.Recordset Dim SQL As String, SQL2 As String dbPath = "table.accdb" dbConnectStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath & ";" SQL = "INSERT INTO Jun_pre (ProductName,DESCRIPTION,SKU,MT,(mt),MRP,Remark,no_of_units_in_a_case) VALUES (""aa"",""bb"",""test"",""testUnit"",""1"",""2"",,""3"",,""4"");" With cnt .Open dbConnectStr 'some other string was there .Execute (SQL) .Close End With End Sub

    Read the article

  • Cannot update any cells in datagrid in vb6

    - by Hybrid SyntaX
    Hello I'm trying to update a row in datagrid but the problem is that i can't even change its cell values I had set my datagrid AllowUpdate property to true , but i can't still change any cell values Option Explicit Dim conn As New ADODB.Connection Dim cmd As New ADODB.Command Dim recordset As New ADODB.recordset Public Action As String Public Person_Id As Integer Public Selected_Person_Id As Integer Public Phone_Type As String Public Sub InitializeConnection() Dim str As String str = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" + App.Path + "\phonebook.mdb;" & _ "Persist Security Info=False" conn.CursorLocation = adUseClient If conn.state = 0 Then conn.ConnectionString = str conn.Open (conn.ConnectionString) End If End Sub Public Sub AbandonConnection() If conn.state <> 0 Then conn.Close End If End Sub Public Sub Persons_Read() Dim qry_all As String ' qry_all = "select * from person,web,phone Where web.personid = person.id And phone.personid = person.id" qry_all = "SELECT * FROM person order by id" Call InitializeConnection cmd.CommandText = qry_all cmd.CommandType = adCmdText Set cmd.ActiveConnection = conn If conn.state = 1 Then Set recordset = cmd.Execute() End If BindDatagrid End Sub Private Function Person_Delete(id As Integer) Dim qry_all As String qry_all = "Delete * from person where person.id= " & id & " " Call InitializeConnection cmd.CommandText = qry_all cmd.CommandType = adCmdText Set cmd.ActiveConnection = conn If conn.state = 1 Then Set recordset = cmd.Execute() End If dg_Persons.Refresh End Function Private Function Person_Update() End Function Public Sub BindDatagrid() Set Me.dg_Persons.DataSource = recordset Me.dg_Persons.Refresh dg_Persons.Columns(0).Visible = False dg_Persons.Columns(4).Visible = False dg_Persons.Columns(1).Caption = "Name" dg_Persons.Columns(2).Caption = "Family" dg_Persons.Columns(3).Caption = "Nickname" dg_Persons.Columns(5).Caption = "Title" dg_Persons.Columns(6).Caption = "Job" End Sub Public Function DatagridReferesh() Call Me.Persons_Read End Function Private Sub cmd_Add_Click() frm_Person_Add.Caption = "Add a new person" frm_Person_Add.Show End Sub Private Sub cmd_Business_Click() ' frm_Phone.Caption = "Business Phones" frm_Phone.Phone_Type = "Business" frm_Phone.Person_Id = Selected_Person_Id frm_Phone.Tag = Selected_Person_Id frm_Phone.Show End Sub Private Sub cmd_Delete_Click() Dim msg_input As Integer msg_input = MsgBox("Are you sure you want to delete this person ?", vbYesNo) If msg_input = vbYes Then Person_Delete Selected_Person_Id MsgBox ("The person is deleted") frm_Phone.DatagridReferesh End If End Sub Private Sub cmd_Home_Click() 'frm_Phone.Caption = "Home Phones" frm_Phone.Phone_Type = "Home" frm_Phone.Person_Id = Selected_Person_Id frm_Phone.Tag = Selected_Person_Id frm_Phone.Show End Sub Private Sub cmd_Update_Click() If Not Selected_Person_Id = 0 Then frm_Person_Edit.Person_Id = Selected_Person_Id frm_Person_Edit.Show Else MsgBox "No person is selected" End If End Sub Public Function AddParam(name As String, param As Variant, paramType As DataTypeEnum) As ADODB.Parameter If param = "" Or param = Null Then param = " " End If Dim objParam As New ADODB.Parameter Set objParam = cmd.CreateParameter(name, paramType, adParamInput, Len(param), param) objParam.Value = Trim(param) Set AddParam = objParam End Function Private Sub Command1_Click() DatagridReferesh End Sub Private Sub Command2_Click() frm_Internet.Person_Id = Selected_Person_Id frm_Internet.Show End Sub Private Sub dg_Persons_BeforeColEdit(ByVal ColIndex As Integer, ByVal KeyAscii As Integer, Cancel As Integer) ' MsgBox ColIndex ' dg_Persons.Columns(ColIndex).Text = "S" ' dg_Persons.Columns(ColIndex).Locked = False ' dg_Persons.Columns(ColIndex).Text = "" 'dg_Persons.Columns(ColIndex).Value = "" 'Person_Edit dg_Persons.Columns(0).Value, dg_Persons.Columns(1).Value, dg_Persons.Columns(2).Value,dg_Persons.Columns(3).Value,dg_Persons.Columns(4).Value, dg_Persons.Columns(5).Value End Sub Private Sub dg_Persons_BeforeColUpdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer) MsgBox ColIndex End Sub Private Sub dg_Persons_Click() If dg_Persons.Row <> -1 Then dg_Persons.SelBookmarks.Add Me.dg_Persons.RowBookmark(dg_Persons.Row) Selected_Person_Id = Val(dg_Persons.Columns(0).Value) End If End Sub Private Sub Form_Load() ' dg_Persons.AllowUpdate = True ' dg_Persons.EditActive = True Call Persons_Read dg_Persons.AllowAddNew = True dg_Persons.Columns(2).Locked = False End Sub Private Function Person_Edit(id As Integer, name As String, family As String, nickname As String, title As String, job As String) InitializeConnection cmd.CommandText = "Update person set name=@name , family=@family , nickname=@nickname , title =@title , job=@job where id= " & id & "" cmd.Parameters.Append AddParam("name", name, adVarChar) cmd.Parameters.Append AddParam("family", family, adVarChar) cmd.Parameters.Append AddParam("nickname", nickname, adVarChar) cmd.Parameters.Append AddParam("title", title, adVarChar) cmd.Parameters.Append AddParam("job", job, adVarChar) cmd.ActiveConnection = conn cmd.CommandType = adCmdText cmd.Execute End Function Private Function Person_Search(q As String) Dim qry_all As String qry_all = "SELECT * FROM person where person.name like '%" & q & "%' or person.family like '%" & q & "%' or person.nickname like '%" & q & "%'" Call InitializeConnection cmd.CommandText = qry_all cmd.CommandType = adCmdText Set cmd.ActiveConnection = conn If conn.state = 1 Then Set recordset = cmd.Execute() End If BindDatagrid End Function Private Sub mnu_About_Click() frm_About.Show End Sub Private Sub submnu_exit_Click() End End Sub Private Sub txt_Search_Change() Person_Search txt_Search.Text End Sub Thanks in advance

    Read the article

  • The instruction at “0x7c910a19” referenced memory at “oxffffffff”. The memory could not be “read”

    - by ClareBear
    Hello guys/girls I have a small issue, I receive the following error before the .vbs terminates. I don't know why this error is thrown. Below is the process of the .vbs file: Call ImportTransactions() Call UpdateTransactions() Function ImportTransactions() Dim objConnection, objCommand, objRecordset, strOracle Dim strSQL, objRecordsetInsert Set objConnection = CreateObject("ADODB.Connection") objConnection.Open "DSN=*****;UID=*****;PWD==*****;" Set objCommand = CreateObject("ADODB.Command") Set objRecordset = CreateObject("ADODB.Recordset") strOracle = "SELECT query here from Oracle database" objCommand.CommandText = strOracle objCommand.CommandType = 1 objCommand.CommandTimeout = 0 Set objCommand.ActiveConnection = objConnection objRecordset.cursorType = 0 objRecordset.cursorlocation = 3 objRecordset.Open objCommand, , 1, 3 If objRecordset.EOF = False Then Do Until objRecordset.EOF = True strSQL = "INSERT query here into SQL database" strSQL = Query(strSQL) Call RunSQL(strSQL, objRecordsetInsert, False, conTimeOut, conServer, conDatabase, conUsername, conPassword) objRecordset.MoveNext Loop End If objRecordset.Close() Set objRecordset = Nothing Set objRecordsetInsert = Nothing End Function Function UpdateTransactions() Dim strSQLUpdateVAT, strSQLUpdateCodes Dim objRecordsetVAT, objRecordsetUpdateCodes strSQLUpdateVAT = "UPDATE query here SET [value:costing output] = ([value:costing output] * -1)" Call RunSQL(strSQLUpdateVAT, objRecordsetVAT, False, conTimeOut, conServer, conDatabase, conUsername, conPassword) strSQLUpdateCodes = "UPDATE query here SET [value:costing output] = ([value:costing output] * -1) different WHERE clause" Call RunSQL(strSQLUpdateCodes, objRecordsetUpdateCodes, False, conTimeOut, conServer, conDatabase, conUsername, conPassword) Set objRecordsetVAT = Nothing Set objRecordsetUpdateCodes = Nothing End Function It does both the import and update and seems to throw this error after. If I comment out the ImportTransactions it doesnt throw a error, however I have produced similar code for another vbs file and this does not throw any errors Thanks in advance for any help, Clare

    Read the article

  • Reading Foxpro database date field using PHP

    - by Bill Yang
    I've wrote a PHP script to export a Foxpro database to other formats by using ADODB (http://phplens.com/lens/adodb) library to access Foxpro OLE DB provider. Everything worked fine except the date fields are mangled and become like these: 11/17-/2-00 3/4/-20-08 By comparing to actual data I can guess that it is probably in the format of MM/DD/YYYY or m/d/YYYY. How can I properly export the date field?

    Read the article

  • Running a simple VBA script to test a connection

    - by brohjoe
    I'm trying to test the connection of a GoDaddy SQL Server database. I'm getting an 'invalid connection string attribute.' What's wrong with this script? Dim cnn As ADODB.Connection Dim canConnect As Boolean Public Sub TestConnection() Set cnn = New ADODB.Connection cnn.Open "Provider=sqloledb;Data Source=GoDaddyServer.com;Initial Catalog=dBase1;UserID=userID; Password='password';" If cnn.State = adStateOpen Then canConnect = True cnn.Close End If MsgBox canConnect End Sub

    Read the article

  • ASP Classic, SQL 2008, XML Output, and DSN vs DSN-Less Produces Chinese Letters

    - by RoLYroLLs
    I've been having a problem for the past month and can't seem to figure out what is wrong. Here's the setup and a little background. Background: I have a web-host who was running my website on Windows Server 2003 and SQL Server 2000. One of my webpages returned a result set from a stored procedure from the SQL server as xml. Below is the code: Stored Procedure: select top 10 1 as tag , null as parent , column1 as [item!1!column1!element] , column2 as [item!1!column2!element] from table1 for XML EXPLICIT ASP Page: index.asp Call OpenConn Set cmd = Server.CreateObject("ADODB.Command") With cmd .ActiveConnection = dbc .CommandText = "name of proc" .CommandType = adCmdStoredProc .Parameters.Append .CreateParameter("@RetVal", adInteger, adParamReturnValue, 4) .Parameters.Append .CreateParameter("@Level", adInteger, adParamInput, 4, Level) End With Set rsItems = Server.CreateObject("ADODB.Recordset") With rsItems .CursorLocation = adUseClient .CursorType = adOpenStatic .LockType = adLockBatchOptimistic Set .Source = cmd .Open Set .ActiveConnection = Nothing End With If NOT rsItems.BOF AND NOT rsItems.EOF Then OutputXMLQueryResults rsItems,"items" End If Set rsItems = Nothing Set cmd = Nothing Call CloseConn Sub OpenConn() strConn = "Provider=SQLOLEDB;Data Source=[hidden];User Id=[hidden];Password=[hidden];Initial Catalog=[hidden];" Set dbc = Server.CreateObject("ADODB.Connection") dbc.open strConn End Sub Sub CloseConn() If IsObject(dbc) Then If dbc.State = adStateOpen Then dbc.Close End If Set dbc = Nothing End If End Sub Sub OutputXMLQueryResults(RS,RootElementName) Response.Clear Response.ContentType = "text/xml" Response.Codepage = 65001 Response.Charset = "utf-8" Response.Write "" Response.Write "" While Not RS.EOF Response.Write RS(0).Value RS.MoveNext WEnd Response.Write "" Response.End End Sub Present: All was working great, until my host upgraded to Windows Server 2008 and SQL Server 2008. All of the sudden I was getting results like this: From Browser: From View Source: However, I found that if I use a DSN connection strConn = "DSN=[my DSN Name];User Id=[hidden];Password=[hidden];Initial Catalog=[hidden];" it works perfectly fine! My current host is not going to support DSN any longer, but that's out of scope for this issue. Someone told me to use an ADO.Stream object instead of a Recordset object, but I'm unsure how to implement that. Question: Has anyone run into this and found a way to fix it? What about that ADO.Stream object, can someone help me with a sample that would fit my code?

    Read the article

  • Empty Datagrid problem in VB6

    - by Hybrid SyntaX
    Hello Recently, i encountered a problem; when I bind a recordset to datagrid ,and run the application the datagrid is not populated even though recordset has data I use the following code Option Explicit Dim conn As New ADODB.Connection Dim cmd As New ADODB.Command Dim recordset As New ADODB.recordset Private Sub InitializeConnection() Dim str As String str = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" + App.Path + "\phonebook.mdb;" & _ "Persist Security Info=False" conn.CursorLocation = adUseClient conn.ConnectionString = str conn.Open (conn.ConnectionString) End Sub Private Sub AbandonConnection() If conn.State <> 0 Then conn.Close End If End Sub Private Sub Persons_Read() Dim qry_all As String ' qry_all = "select * from person,web,phone Where web.personid = person.id And phone.personid = person.id" qry_all = "SELECT * FROM person" Call InitializeConnection cmd.CommandText = qry_all cmd.CommandType = adCmdText Set cmd.ActiveConnection = conn If conn.State = 1 Then Set recordset = cmd.Execute() End If Call BindDatagrid Call AbandonConnection End Sub Private Function Person_Add() End Function Private Function Person_Delete() End Function Private Function Person_Update() End Function Private Sub BindDatagrid() Set dg_Persons.DataSource = recordset dg_Persons.Refresh End Sub Private Sub cmd_Add_Click() Person_Add End Sub Private Sub cmd_Delete_Click() Person_Delete End Sub Private Sub cmd_Update_Click() Person_Update End Sub Private Sub Form_Load() Call Persons_Read End Sub Private Sub mnu_About_Click() frm_About.Show End Sub Thanks in advance

    Read the article

  • Torrentflux broke after upgrade

    - by parker.sikand
    A working torrentflux setup seems to have gone broken after upgrading PHP to 5.3 and Postrgres to 9.2beta3 on a FreeBSD 8.2 server. The login screen will show up fine, but after clicking the login button, I get an error : Fatal error: Call to undefined function pg_escape_string() in \ /usr/home/parker/tf/html/inc/lib/adodb/drivers/adodb-postgres64.inc.php \ on line 241 Seems to be an error with PHP and the pgsql php package. The phppgsql package itself is not totally broken because I'm using it to host database driven apps on this server. This is the first and only error I'm seeing from it. How might I go about fixing this problem?

    Read the article

  • What is ADO ?

    - by Aamir Hasan
    What is ADO? ADO is a Microsoft technologyADO stands for ActiveX Data ObjectsADO is a Microsoft Active-X componentADO is automatically installed with Microsoft IISADO is a programming interface to access data in a databaseAccessing a Database from an ASP Page The common way to access a database from inside an ASP page is to: Create an ADO connection to a databaseOpen the database connectionCreate an ADO recordsetOpen the recordsetExtract the data you need from the recordsetClose the recordsetClose the connectionExample  <%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("/db/northwind.mdb"))set rs = Server.CreateObject("ADODB.recordset")rs.Open "Select * from Customers", conndo until rs.EOF    for each x in rs.Fields       Response.Write(x.name)       Response.Write(" = ")       Response.Write(x.value & "<br />")    next    Response.Write("<br />")    rs.MoveNextlooprs.closeconn.close%> 

    Read the article

  • What is ADO ?

    - by Aamir Hasan
    What is ADO? ADO is a Microsoft technologyADO stands for ActiveX Data ObjectsADO is a Microsoft Active-X componentADO is automatically installed with Microsoft IISADO is a programming interface to access data in a databaseAccessing a Database from an ASP Page The common way to access a database from inside an ASP page is to: Create an ADO connection to a databaseOpen the database connectionCreate an ADO recordsetOpen the recordsetExtract the data you need from the recordsetClose the recordsetClose the connectionExample  <%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("/db/northwind.mdb"))set rs = Server.CreateObject("ADODB.recordset")rs.Open "Select * from Customers", conndo until rs.EOF    for each x in rs.Fields       Response.Write(x.name)       Response.Write(" = ")       Response.Write(x.value & "<br />")    next    Response.Write("<br />")    rs.MoveNextlooprs.closeconn.close%> 

    Read the article

  • How do I use a datetime variable with createparameter in classic ASP?

    - by Frank Schmitt
    I'm having a heck of a time trying to create a parameterized query that binds a date variable into a stored procedure call: twoyearsago = dateadd("yyyy", -2, date()) DataConn.ConnectionString = myConnectionString DataConn.Open Set rs = Server.CreateObject("ADODB.Recordset") Set DataCmd = Server.CreateObject("ADODB.Command") DataCmd.ActiveConnection = DataConn DataCmd.CommandText = "exec myStoredProc ?, ?" DataCmd.Parameters.Append DataCmd.CreateParameter("@start", adDate, , 10, date()) DataCmd.Parameters.Append DataCmd.CreateParameter("@end", adDate, , 10, twoyearsago) rs.Open DataCmd The stored proc returns nothing (indicating the dates aren't making it through). If I hard code dates in the query, e.g.: DataCmd.CommandText = "exec myStoredProc '01/01/2008', '01/01/2010'" I get the results I would expect. Calling CStr on my dates (if that makes a difference) returns them in the above format.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8  | Next Page >