sqlbulkcopy imports only 17837 out of 67000 rows - iis

The sqlbulkcopy function works fine in my local environment but when I deploy it to IIS it only imports 17837 out of the 67K odd rows. Does anybody know what can cause this issue?

Actually the problem was with the Excel connection string I was missing the 'IMEX=1' at the very end. The correct connection string is - Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\uploaded.xlsx;Extended Properties='Excel 12.0 Xml;HDR=YES;IMEX=1'"

Related

querying excel spreadsheet in VBA using sql

I am trying to query an excel file from VBA using SQL queries; I am working on a windows 7 machine 64 bit with office 2007 installed. I am using the connection string below taken from here
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\TradeLogSettings.xlsm;Extended Properties=Excel 12.0 Macro;HDR=YES;
However when I try to open the connection as follow
'ConnDbString is the above connection string
If (Glob_Conn.State = 0) Then
Glob_Conn.Open (ConnDbString)
End If
I get the error as per the attached screenshot
any idea about what I am doing wrong with the connection string ?
error on Glob_Conn.Open
UPDATE 1
The solution that I found is to use this connection string
Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm,*.xlsb)};DBQ=C:\TradeLogSettings.xlsm
if anyone knows a better connection string for my purpose is welcomed.
I think the quotation marks are missing. Try this.
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\TradeLogSettings.xlsm;Extended Properties="Excel 12.0 Xml;HDR=YES";
The solution that I found is to use this connection string
Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm,*.xlsb)};DBQ=C:\TradeLogSettings.xlsm

How to fix error "Cannot update. Database or object is read-only." Excel Database Automation Anywhere

I am accessing an excel file stored on a shared drive for now a couple of months without errors. All of a sudden, we have this issue popping out:
Cannot update. Database or object is read-only.
My original connection string looked like this:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source="<FileName>";Extended Properties="Excel 12.0 Xml;HDR=Yes;".
I have tried the following one:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source="<FileName>";Extended Properties="Excel 12.0 Xml;HDR=Yes;Readonly=0;"
and
Provider=Microsoft.ACE.OLEDB.12.0;Data Source="<FileName>";Extended Properties="Excel 12.0 Xml;HDR=Yes;READONLY=FALSE;"
but nothing provides good results.
I need to connect to this excel workbook and get the data in order to perform some business critical process, but nothing works so far as it always provides me with the mentioned error.
Any recommendation?
A solution that worked for me in that case was adding IMEX=1 at the end of the connection query.

vb.net Cannot update. Getting error "Database or object is read-only." when just trying to READ from excel file

I'm more than willing to accept other suggestions on ways to accomplish what I want to do. I am trying to read some lines from an excel spreadsheet that the user uploads to my application. The web server where this will eventually reside does not have excel installed on it, which makes referencing things like Microsoft.Office.Interop.Excel.dll in my project impossible. So I've been looking for ways to read the excel file so that will work with this situation. The best way I've found so far is to use Microsoft.Jet.OLEDB.4.0 to connect to the excel file like a datasource. Here is a small snippet of I've put together so far:
Dim excelFileName As String = "C:\\Import\\K12Mercury.xlsx"
Dim conn As New OleDb.OleDbConnection(String.Format("provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & excelFileName & "; Extended Properties='Excel 8.0;HDR=YES;'"))
conn.Open()
The program fails on the conn.Open() line with the error:
cannot update. database or object is read-only
I don't know why this is happening or if this is even the best route to use to be able to read from an excel file in an environment where excel is not installed. Will someone please help me? Thanks in advance.

ODBC Driver has become erratic when making connection and processing SQL query

I have an Excel Macro Workbook (binary extension) that suddenly has developed 2 issues occasionally (sometimes it runs fine).
#1 Issue - Occasionally there is an error on Line 5
It appears the connection does not open. We get the error:
Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x7f8 Thread 0x1174 DBC
#2 Issue - Occasionally there is an error on Line 7
It appears the SQL can not run. It indicates the Worksheet tab can not be found even though it does exist. Note for this error we have no issue with Line 5 (Open Connection). The error that displays is:
[Microsoft][ODBC Excel Driver] The microsoft jet database engine could not find the object 'Worksheet Name'. Make sure the object exists...
For Issue #2 once we close the error dialog box and THE MACRO GETS DELETED !!!
Notes
The code module has not been changed in years Some days we get no errors/issues
This issue occurs for multiple Excel workbooks run by multiple people that run different VBA code blocks. However 1 of the code blocks is the same across all these macros which is the code snippet above.
The source data has not changed in years in terms of formatting or volume.
All these workbooks are on a Network server.
We are on Windows7/Excel 2010/ODBC Excel Driver (xls xlsx xlsm xlsb)
14.00.7180.5000
Code Snippet
1-Set adoConn = Nothing
2-Set adoRS = Nothing
3-Application.EnableCancelKey = xldisabled
4-strConn = "Driver={Microsoft Excel Driver (*.xls,*.xlsx,*.xlsm,*.xlsb)};DriverId=1046;Dbq=" & strFileName & ";IMEX=1;"
5-Set adoConn = New ADODB.Connection: adoConn.Open strConn
6-Application.EnableCancelKey = xlInterrupt
7-Set adoRS = New ADODB.Recordset:adoRS.Open Source:=strSQL,ActiveConnection:=adoConn
I'm curious as to why you're using ODBC to connect Excel to another Excel file, as opposed as to linking the data directly.
Intermittent connection problems point to a network issue. I would suggest removing and re-creating the ODBC connection, but I'd first want to confirm the value of strFileName as referred to in the connection string. Is it an actual server on your internal network, or an external source? (ie, is it a UNC path?)
An intermittent Unable to open registry key error likely sounds worse than it is; when having connection problems, Windows & Excel will easily get confused as to what the real problem is.
It sounds like your setup has been in place, possibly un-maintained, for a long time. When is the last time the client and server were rebooted? (Should be nightly.) Defrag, disk cleanup, etc?
As for the issue of the macro "getting deleted" when you close an error dialog, I'd need to see proof of that. I think you're misunderstanding something, unless you're re-writing the macro from scratch each time this happens..

VBA odbc connection accessing a single library only

I have successfully connected to an as400 server. But whenever i execute an sql statement
select * from nosd0
It doesn't work, because nosd0 is in lib1/fil1(nosd0)
it gives an error saying nosd0 is not in lib2.
When I execute the query on STRSQL on as400 it works fine.
I tried creating an alias and it's malfunctioning. Please I really need some help on this one
Alias is working, I am accessing the wrong file.
Ok I figured out the problem, this will also help all those who wants to connect to their AS400 iSeries using VBA. ;)
My problem above is that when I try my Query on the box, it accesses lib1/nosd0, and in VBA, I was trying to get lib2/fil1(nosd0) which is a description of the table nosdo itself. The simple solution is to query
select * from lib1.nosd0
More on that when connecting to an AS400 iSeries using ODBC, there is a parameter called DBQ
Connection String Parameters
My final connection string would be.
ConnectString = "Driver={ISeries Access ODBC Driver};System=" & DCServer(I) & ";Uid=--;Pwd=--;NAM=0;DBQ=lib1,*ALL;"

Resources