473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Insert a data into a SQL Server 2000 from Excel file using ASP

4
Hello All,

I would like to insert/update a database table using excel file.

I have a list of products in an excel file. If product exist in a database table tblproduct than it should update the content and if product does not exist it should insert the new row.

I am using sql server 2000.In excel I have 16 columns.

tblproduct has following columns

ID (int) - Identity column
ProductCode (nvarachar)
ProductName (nvarchar)
Description (nvarchar)
costprice(money)
retailprice(money)
saleprice(money)
splsaleprice(money)
splboxprice(money)
boxqty(int)
boxprice(money)
stock_level(int)
weight(float)
Image(nvarchar)
display(int)
brandid(int)

I was trying to use follwoing code but gave me the error.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Set objConn = Server.CreateObject("ADODB.Connection") 
  3. objConn.open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=c:\test.xls; Extended Properties=Excel 8.0;" 
  4. set objRS = server.createObject("ADODB.recordset") 
  5. objRS.open objConn, "SELECT * FROM tblproduct" 
  6.  
  7. set conn=Server.CreateObject("ADODB.Connection")  
  8. conn.Open "dbConnectionStr" 
  9. set RS = server.createObject("ADODB.recordset") 
  10. RS.open conn, "SELECT * FROM tblproduct", adOpenDynamic, adLockOptimistic 
  11.  
  12. do until objRS.eof 
  13.    RS.addnew 
  14.    for each x in objRS 
  15.       RS(x) = objRS(x) 
  16.    next 
  17.    RS.update 
  18.    objRS.moveNext 
  19. loop 
  20.  
  21. %>
  22.  
***********************[Error]*************************
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
***********************[/Error]*************************

Any help will be really appreciated.

Thanks in advance.
Sep 30 '08 #1
1 2734
jhardman
3,406 Expert 2GB
***********************[Error]*************************
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
***********************[/Error]*************************

Any help will be really appreciated.

Thanks in advance.
The error just means that one of the data types in the excel file doesn't match the data type in the db. You need to find out the exact place the error is occurring - try this:
Expand|Select|Wrap|Line Numbers
  1. do until objRS.eof 
  2.    RS.addnew 
  3.    for each x in objRS 
  4.       response.write "<!-- adding " & x & "; datatype: " x.type & " -->" & vbNewLine
  5.       RS(x) = objRS(x) 
  6.    next 
  7.    RS.update 
  8.    objRS.moveNext 
  9. loop 
  10.  
  11. %>
  12.  
This will print out a new comment for each line, the last comment should tell you the field that is causing the error. Let me know if this helps.

Jared
Oct 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: | last post by:
Hi, I am an intermediate computer science student and I am in need of a "macro type" tool/language that will let me automate a data entry process. The data entry is rather simple but requires...
5
by: Ervs Sevilla via SQLMonster.com | last post by:
BCP and Bulk Insert to Linked Servers Hi guys! Heres my set up: 1) Im using Win2003 with MS SQL 2000 2) I have a linked server in SQL Server pointing to an MS Access DB. Why MS Access?...
6
by: pk | last post by:
Sorry for the piece-by-piece nature of this post, I moved it from a dormant group to this one and it was 3 separate posts in the other group. Anyway... I'm trying to bulk insert a text file of...
2
by: maltchev | last post by:
i need to insert data from an xml file into sql server table. the xml file contains only one record. how to insert the data? how to map the names of the fields in the xml file and the table?...
4
by: washoetech | last post by:
Hello, I am working on a project where I need to be able to grab the data from an Excel spreadsheet and create a new table in my database based on the columns in the spreadsheet. After the...
8
by: carlospedr | last post by:
I have to insert data from about 30 tables into a single table (Users), to do so i used a cursor and a bit of dynamic sql, this should work fine if the tables have to do the select from had the...
11
by: Ted | last post by:
OK, I tried this: USE Alert_db; BULK INSERT funds FROM 'C:\\data\\myData.dat' WITH (FIELDTERMINATOR='\t', KEEPNULLS, ROWTERMINATOR='\r\n');
3
by: Dmitri | last post by:
Hello! I have a developer that is playing around with some SQL statements using VB.NET. He has a test table in a SQL 2000 database, and he has about 2000 generated INSERT statements. When the...
2
by: cbadchris | last post by:
I am writing an import function with asp, and excel that writes imported excel sheets to to several SQL tables and everything works fine until it reaches the "add data for search" section or query 2....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.