Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

import excel to sql

Status
Not open for further replies.

b00gieman

Programmer
Jul 9, 2007
60
DE
Hi!
I have developed an application for uploading data from excel to ms sql.I'm getting the following error message:

3001:Arguments are of the wrong type, are out of acceptable
range, or are in conflict with one another

The code I'm using:
Code:
<%
    
    Dim ADOrs
    Dim SQLstr  
    Dim lngRecsAff
    'As ADODB.Connection
    'As String
    'As Long
    set ADOrs = Session("DataConn")
    'Set ADOConn = Server.CreateObject("ADODB.Connection")
    'ADOConn.Open "Provider=SQLOLEDB;Data Source=tmav035a;" & _
    '    "Initial Catalog=shopping_TSR.mds;User ID=Admin;"'Password=;"
    
    'Import by using OPENROWSET and object name.
    SQLstr = "SELECT * INTO shopping_TSRM FROM " &_
        "OPENROWSET('Microsoft.Jet.OLEDB.4.0', " &_
        "'Excel 8.0;Database=C:\inetpub\[URL unfurl="true"]wwwroot\Test_AssetDB\fileuploader\upload\tmb2.xls',[/URL] " & _
        "'SELECT * FROM [Sheet1$]')"
    'Debug.Print strSQL
    ADOrs.Execute(strSQL)', lngRecsAff, adExecuteNoRecords
    'Debug.Print "Records affected: " & lngRecsAff

    'cn.Close
    'Set cn = Nothing
    'Response.Write(ADOrs.ErrorStr)
    Response.Write("ADOrs error!!<br />" &ADOrs.ErrorStr & "<br />")


%>

Can somebody tell me what's causing the error message?
Thanks in advance!
 
Most likely attempting to insert a space " " character or an empty string "" into a numeric field.

Try setting all database fields to type varchar and running it again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top