473,513 Members | 3,895 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 myConnectionString As String = "Data Source=dr-ny-sql003;Initial
Catalog= TEST_TAMMY;Integrated Security=YES"
Dim myConnection As SqlConnection = New
SqlConnection(myConnectionString)
'Dim csvInputFile As String = "R:\Spam BB Search Engine
Application\Exports\GridExport.txt"
Dim csvInputFile As String = "C:\GridExport.txt"
Dim ds As New DataSet
'Dim m_strConnection As String = "Data Source=" &
lstServers.SelectedValue & ";Initial Catalog= SpamBank;Integrated
Security=SSPI"

myConnection = New SqlConnection
myConnection.ConnectionString = myConnectionString
myConnection.Open()

' 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.Test_Tammy FROM
[Text;HDR=YES;DATABASE=" & csvInputFile & "]"
'strSQL = "SELECT * INTO [dr-ny-
sql003].TEST_TAMMY.dbo.Test_Tammy FROM
OPENROWSET('msdasql,Driver={Microsoft Text Driver
(*.txt;*.csv)};DEFAULTDIR=R:\Spam BB Search Engine Application\Exports
\;Extensions=txt;','select * from GridExport.txt'"
strSQL = "SELECT * INTO [dr-ny-
sql003].TEST_TAMMY.dbo.temp_test_spam FROM
OPENROWSET('msdasql,Driver={Microsoft Text Driver
(*.txt;*.csv)};DEFAULTDIR=C:\;Extensions=txt;','se lect * from
GridExport.txt'"

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

objCommand.CommandText = strSQL
objCommand.ExecuteNonQuery()
myConnection.Close()
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 836

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

Similar topics

11
3054
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...
29
4179
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
2545
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:...
0
1079
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...
3
2015
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
1220
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)...
1
2563
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...
5
5298
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...
0
7394
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. ...
0
7559
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...
1
7123
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...
0
7542
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...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5100
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...
0
1611
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
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
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...

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.