473,385 Members | 1,474 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,385 software developers and data experts.

Excel transfer to SQL using VB

Hi,
I have an application where I transfer an excel file to a table on SQL through an adp file. The excel file does change so I pass the name parameter from a cmd line. The excel file has a specific range defined of 20,000 records. Currently the process is using ac.DoCmd.TransferSpreadsheet acImport and it pulls in all 30,000 records even though there isn't data in all 20,000 records (lots of nulls). How can I get the process to only transfer the data where it isn't null?

Thanks.
Jun 22 '06 #1
10 16533
sashi
1,754 Expert 1GB
hi there,

wll i feel the "null" problem is taken care of when it comes to comma delimited .txt, .csv format file.. give it a try.. good luck my fren..
Jun 22 '06 #2
CaptainD
135 100+
VB can use the NZ() function, have you looked into that?
Jun 22 '06 #3
Where do you place this in the code?
Jul 16 '06 #4
Hello ,
I have an application in vb that must gets excell applicatiom and transfer data from excell worksheet to table of sql? how can i do this work? tanks for reply.
Jul 26 '06 #5
mysql
1
hi how can work with vb and mysql?
pls reply early
Aug 30 '06 #6
Roytop
2
Hi!
Use this little VBA code for uploading Excel data to MS SQL database.

Sub upload()
Set connAS400 = CreateObject("ADODB.Connection")
connAS400.Open (" Provider=SQLOLEDB.1;InitialCatalog=dbname;Server=s ervername;UID=user;PWD=password; ")
ConnOpenAS400 = True
connAS400.CommandTimeout = 100

For i = 1 To Workbooks(1).Worksheets(1).UsedRows.Count
query = "INSERT Roytop..test (text) VALUES ('" & Workbooks(1).Worksheets(1).Range("A" & i) & "')"
Set result = connAS400.Execute(query)
Next

result.Close
Set result = Nothing
End Sub
Sep 13 '06 #7
hi how can work with vb and mysql?
pls reply early
simply.. just install the mysql database and mysql odbc driver.. then in visual basic just call the odbc driver to connect into the mysql database..in then..u have now to code the basic query of sql.. thanks..
Sep 14 '06 #8
xpcer
51
simply.. just install the mysql database and mysql odbc driver.. then in visual basic just call the odbc driver to connect into the mysql database..in then..u have now to code the basic query of sql.. thanks..
can i have the codes? thanks before
Sep 16 '06 #9
xpcer
51
Hi!
Use this little VBA code for uploading Excel data to MS SQL database.

Sub upload()
Set connAS400 = CreateObject("ADODB.Connection")
connAS400.Open (" Provider=SQLOLEDB.1;InitialCatalog=dbname;Server=s ervername;UID=user;PWD=password; ")
ConnOpenAS400 = True
connAS400.CommandTimeout = 100

For i = 1 To Workbooks(1).Worksheets(1).UsedRows.Count
query = "INSERT Roytop..test (text) VALUES ('" & Workbooks(1).Worksheets(1).Range("A" & i) & "')"
Set result = connAS400.Execute(query)
Next

result.Close
Set result = Nothing
End Sub

For i = 1 To Workbooks(1).Worksheets(1).UsedRows.Count
query = "INSERT Roytop..test (text) VALUES ('" & Workbooks(1).Worksheets(1).Range("A" & i) & "')"
Set result = connAS400.Execute(query)
Next

cannot execute....
Sep 16 '06 #10
CaptainD
135 100+
For i = 1 To Workbooks(1).Worksheets(1).UsedRows.Count
query = "INSERT Roytop..test (text) VALUES ('" & Workbooks(1).Worksheets(1).Range("A" & i) & "')"
Set result = connAS400.Execute(query)
Next

cannot execute....
Did you change the values he gave you to match your configurations?
Sep 27 '06 #11

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

Similar topics

3
by: Otie | last post by:
I am trying to copy the cell contents in an MSFLXGRD control (using VB5) into Excel, retaining the foreground colors of the text and numbers. I have tried using the Clipboard.SetText...
1
by: ganesh_infosys | last post by:
can anybody tell me how to transfer xml data to an excel template (worksheet) using asp.net ?
1
by: barma16 | last post by:
I've hit a bit of a brick wall here, and could use some advice. I have an Access application whose output is a four-tab Excel spreadsheet where three of the four tabs are the result of database...
3
by: Carlos Magalhaes | last post by:
Hey All, I am doing some excel automation using the excel COM. I can do most of the functions and its working well until I come across a formula. I can run a formula and insert the formula...
3
by: George | last post by:
Sub ExcelToListBox() Dim xRange As Object Dim ary Dim xValue As String xRange = oXL.Range("A1:A9") 'has letters A-H ary = xRange.value xValue = ary(3, 1) 'xValue = C...
7
by: rdemyan via AccessMonster.com | last post by:
I want to make sure that I'm closing an opened spreadsheet correctly. I've been having some locking up problems. The following code adds a dummy row to the spreadsheet to ensure that that the data...
14
by: cj | last post by:
I want to start a workbook and add sheets to it one at a time. Right now my code opens a workbook and it has 3 sheets alread in it and I don't even know how to move from one to another. Any help...
4
by: vancehome | last post by:
I have a series of macros running everynight creating tons of excel files (using transfer spreadsheet). I then have another program that zips them up and emails them all over the place. It then...
3
by: JohnM | last post by:
I can transfer from a query with DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "Filenam", CPath, True I would like to use a form for the user to select and order data then...
0
by: blainegray | last post by:
Greetings This is one of those Access is not closing Excel problems. The first time through the code works fine. The second time there is a problem. After lots of combinations, I finally...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.