473,672 Members | 3,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

importing into sql server 2005 from visual basic 2008 not creatingtable on the fly

TG
hi!

I am trying to import a text file into a table created on the fly in
SQL Server 2005 since the number of columns can vary depending on what
the user has checked or not.

Here is the code I am using:

Dim myConnectionStr ing As String = "Data Source=dr-ny-sql003;Initial
Catalog= TEST_TAMMY;Inte grated Security=YES"
Dim myConnection As SqlConnection = New
SqlConnection(m yConnectionStri ng)
'Dim csvInputFile As String = "R:\Spam BB Search Engine
Application\Exp orts\GridExport .txt"
Dim csvInputFile As String = "C:\GridExport. txt"
Dim ds As New DataSet
'Dim m_strConnection As String = "Data Source=" &
lstServers.Sele ctedValue & ";Initial Catalog= SpamBank;Integr ated
Security=SSPI"

myConnection = New SqlConnection
myConnection.Co nnectionString = myConnectionStr ing
myConnection.Op en()

' Make sure the .CSV file exists:
If IO.File.Exists( csvInputFile) Then
Try
' ------ Load the data from the .CSV file: --------
Dim strSQL As String
'strSQL = "SELECT * INTO Spambank.dbo.Te st_Tammy FROM
[Text;HDR=YES;DA TABASE=" & csvInputFile & "]"
'strSQL = "SELECT * INTO [dr-ny-
sql003].TEST_TAMMY.dbo .Test_Tammy FROM
OPENROWSET('msd asql,Driver={Mi crosoft Text Driver
(*.txt;*.csv)}; DEFAULTDIR=R:\S pam BB Search Engine Application\Exp orts
\;Extensions=tx t;','select * from GridExport.txt' "
strSQL = "SELECT * INTO [dr-ny-
sql003].TEST_TAMMY.dbo .temp_test_spam FROM
OPENROWSET('msd asql,Driver={Mi crosoft Text Driver
(*.txt;*.csv)}; DEFAULTDIR=C:\; Extensions=txt; ','select * from
GridExport.txt' "

Dim objCommand As SqlClient.SqlCo mmand
objCommand = New SqlClient.SqlCo mmand(strSQL,
myConnection)

objCommand.Comm andText = strSQL
objCommand.Exec uteNonQuery()
myConnection.Cl ose()
Catch ex As Exception
MessageBox.Show ("Error importing the file" &
csvInputFile & ".")
End Try
End If

I am not getting the error message, but neither is the table being
created in the database TEST_TAMMY.

What am I doing wrong?

Thanks in advanced!

Tammy
Jun 27 '08 #1
0 842

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
3074
by: Skc | last post by:
I have a .txt which has been exported as a .csv from an external source. What i need to do is to import this into SQL2000 (into a table) but I need to do special things on the data: 1. I need to look for the first three chars and import rows into separate tables. E.g. if the first three chars begin with CCC, then this row goes into the CCC_table, if it is TTT then into the TTT_table etc... 2. Once I have my tables built up, I need to do...
29
4210
by: Natan | last post by:
When you create and aspx page, this is generated by default: using System; using System.Collections; using System.Collections.Specialized; using System.Configuration; using System.Text; using System.Text.RegularExpressions; using System.Web; using System.Web.Caching;
6
2551
by: Brian Henry | last post by:
Visual Basic 2005 Express: http://download.microsoft.com/download/f/c/7/fc7debaf-4513-4300-9e6a-8fe27be88cd1/vbsetup.exe Visual C# 2005 Express: http://download.microsoft.com/download/2/d/2/2d221839-eaf9-4d91-899e-95a9af12202e/vcssetup.exe Visual C++ 2005 Express: http://download.microsoft.com/download/3/f/3/3f3e65c3-9f57-40ee-a95b-57d49e560883/vcsetup.exe Visual J# 2005 Express:
0
1091
by: Jerry Spivey | last post by:
Hi, I'm a SQL Server DBA and I'm trying to get a listing of the SQL Servers on the network. I installed Visual Basic 2005 Express edition and used the SQL Server 2005 ServerInfo sample which uses SMO (SQL Server Management Objects). I chose SMO over SQL-DMO because SMO seemed to list more SQL Servers including named instances. Everything worked fine on our local domain. I then logged off and connected to the remote domain (in Europe)...
3
2027
by: Goofy | last post by:
The add database ( MDF ) in Visual Studio 2005 seems to be in SQL Server 2005 format as far as I can tell. Does anyone know how I can import tables ( without having to start writing queries ) from Access ? -- Goofy -- Goofy
3
1233
by: cugone | last post by:
I'm looking for a way to import C# namespaces (stored in a *.cs file) into a visual basic 2005 application. I'm attempting to write an application that uses DirectX and all of the helper functions and code for it are written in C#. The normal Imports keyword does not support pathnames as valid assemblies (I may just be doing it wrong, however) to search and the MSDN Library (April 2007 ed.) does not cover how to either.
1
2578
by: =?Utf-8?B?Rmxhbm1hbg==?= | last post by:
I have a tutorial I was working on with Visual Web Developer 2005 express. Very basic stuff intro to asp.net. All was working fine a few days ago. I took my pc home and installed the visual studion 2005 sdk and also visual web developer 2008. Today when I try to run or debug a very basic page I am getting the error" Unable to connect to Visual Studio's Locahost Web server" I get a similar error when trying to run/debug the same project in...
5
5305
by: CAM | last post by:
Hello, I am using SQL Server Express 2008 for my database and Visual Studios 2008 - Visual Basic.Net for my forms. I Gone into VS 2008 and specify the source of data using the Data Sources Windows following the wizard. I have input the Server name using Windows Authentication, select the database name and tested the connection it works fine. I created a form in VS 2008 added text boxes and the data navigator, table adapter. It all...
0
8945
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8844
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8642
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8696
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6254
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4239
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2836
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1836
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.