C# Application - Method To Import Delimeted CSV To Sql Server Table

Jan 26, 2007

Hi,

I'm writing a telecom billing system where it is necessary to import csv delimited files into a sql server table.

1) The csv files to import differ in column arrangement i.e SQL server table arrangement = A, B, C, D whilst CDR = - , A, -, C, D

2) The csv files are delimited via different characters i.e some are del.. by commas some by semi colons

 I can import a CSV file from my application using a BULK INSERT query but only using CSV that resembles the structure of the table exactly

How can I pass a CSV to the table and state where I want each CSV column to fill a column in the SQL SERVER table

Below is how I am managing to pass a CDR to the SQL table that I have pre manufactured to resemble the structure of the SQL table Is there a way I can state which values from the CSV I want to pass to corresponding columns in the SQL table:

 

string conString = @"Provider=SQLOLEDB;Server=(local);Database=Billing;Uid=sa;Pwd=sa;";

for (int i = listBox1.Items.Count - 1; i >= 0; i--)

{

string strSQL;

OleDbConnection objConnection = null;

OleDbCommand objCmd = null;

objConnection = new OleDbConnection(conString);

 

string cdr = listBox1.GetItemText(listBox1.Items[i]);

 

strSQL = "BULK INSERT Campaign FROM '"+ cdr +"' WITH (FIELDTERMINATOR = ',', ROWTERMINATOR = '
')";

OleDbDataReader objDataReader;

 

try

{

objConnection.Open();

objCmd = new OleDbCommand(strSQL, objConnection);

objCmd.ExecuteNonQuery();

objCmd = null;

objDataReader = null;

objConnection.Close();

listBox1.Items.Remove(listBox1.Items[i]);

}

catch (Exception ex)

{

objConnection.Close();

}

objCmd = null;

objConnection = null;

}

 

Regards

 Simon

View 4 Replies


ADVERTISEMENT

SSIS Import From Comma Delimeted Flat File

Nov 27, 2007

I have a data record as below from teh comma delimeted text file.

660,"CAMPO DE GOLF ""LA FINC ALOGORFA,",7941

SQL 2000 DTS loads this data fine whree the second column is loaded as

ABC ""DAT DESC,",



But Unable to load the record using SQL 2005 SSIS.It considers "CAMPO DE GOLF ""LA FINC ALOGORFA as one column and " as column 2. Is there any options to load this type of data using SSIS.

Thanks

View 3 Replies View Related

SQL Server Import And Export Wizard Fails To Import Data From A View To A Table

Feb 25, 2008

A view named "Viw_Labour_Cost_By_Service_Order_No" has been created and can be run successfully on the server.
I want to import the data which draws from the view to a table using SQL Server Import and Export Wizard.
However, when I run the wizard on the server, it gives me the following error message and stop on the step Setting Source Connection


Operation stopped...

- Initializing Data Flow Task (Success)

- Initializing Connections (Success)

- Setting SQL Command (Success)
- Setting Source Connection (Error)
Messages
Error 0xc020801c: Source - Viw_Labour_Cost_By_Service_Order_No [1]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "SourceConnectionOLEDB" failed with error code 0xC0014019. There may be error messages posted before this with more information on why the AcquireConnection method call failed.
(SQL Server Import and Export Wizard)

Exception from HRESULT: 0xC020801C (Microsoft.SqlServer.DTSPipelineWrap)


- Setting Destination Connection (Stopped)

- Validating (Stopped)

- Prepare for Execute (Stopped)

- Pre-execute (Stopped)

- Executing (Stopped)

- Copying to [NAV_CSG].[dbo].[Report_Labour_Cost_By_Service_Order_No] (Stopped)

- Post-execute (Stopped)

Does anyone encounter this problem before and know what is happening?

Thanks for kindly reply.

Best regards,
Calvin Lam

View 6 Replies View Related

How To Split A Delimeted String...

May 9, 2008

 hi,
i have a simple question, i have a sql server table named "Restaurant" and a field "Cuisines",
the values in the field Cuisines contains delimeted string. (e.g. "C1,C2,C3...C10" ,maximum to 10 items or less)
now, i want to split the values from Cuisines ("C1,C2,C3...C10") and passed all of them to a SP parameter.
e.g
@item0 nvarchar = "C1",@item1 nvarchar = "C2",@item2 nvarchar = "C3",@item3 nvarchar = "C4",@item4 nvarchar = "C5",@item5 nvarchar = "C6",@item6 nvarchar = "C7",@item7 nvarchar = "C8",@item8 nvarchar = "C9",@item9 nvarchar = "C10"
 if the field "Cuisines" contains less than 10 items, the value of the remaining parameters is null.
any response will be appreciated. thanks.
 
 

View 5 Replies View Related

Method To Insert All Record From Access Table To SQL Server One

Jul 20, 2005

Anyone know if there is method that can insert all record from a tablein an MS Access 2000 database to a table in MS SQL Server 2000database by a SQL statement? (Therefore, I can execute the statementin my program)--Posted via http://dbforums.com

View 3 Replies View Related

SQL 2012 :: Method To Setup Table Replication Between Server Express?

Aug 12, 2014

Is there any method to setup table replication between you sql server express?

View 3 Replies View Related

SQL Server 2012 :: Set Based Method To Insert Missing Records Into Table - Right Join Not Work

Apr 24, 2014

I have table A (EmployeeNumber, Grouping, Stages)
and
Table B (Grouping, Stages)

Table A could look like the following where the multiple employees could have multiple types and multiple stages.

EmployeeNumber, Type, Stages
100, 1, Stage1
100, 1, Stage2
100, 2, Stage1
100, 2, Stage2
200, 1, Stage1
200, 2, Stage2

Table B is a list of requirements that each employee must have. So every employee must have a type 1 and 2 and the associated stages listed below.

Type, Stage
1, Stage1
1, Stage2
2, Stage1
2, Stage2
2, Stage3
2, Stage4

So I know that each employee should have 2 Type 1's and 4 Type 2's. I hope that makes sense, I'm trying to change my data because ours is very proprietary.

I need to identify employees who do not have all their stages and list the stages they are missing. The final report should only have employees and the associated missing types and stages.

I do a count by employee to see how many types they have to identify the ones that don't have all the types and stages.

My count would look something like this:

EmployeeNumber Type Total
100, 1, 2
100, 2, 2
200, 1, 1
200 1, 2

So I know that employee 100 should have 2 more Type 2's and employee 200 should have 1 more Type 1 and 2 more Type 2's based on the required list.

The problem I'm having is taking that required list and joining to my list of employees with missing data and pulling from it the types and stages that are missing by employee. I thought I could get a list of the employees that are missing information and right join it to the required list where the missing records would be nulls. But, that doesn't work because some employees do have the required information and so I'm not getting any nulls returned.

View 9 Replies View Related

How Can I Import Records From A Sql Server Table In Project1 To Another Sql Server Table In Project2

May 24, 2007

Hi, i have a table with all employee bio-data in a completed project. Iam now working on another project with a table that needs the same data and here iam talking about 300 records that rarely change. Instead of re-entering this data in this new table, i want to import the data from the completed project into a table in this new project. Does any one have any idea how to achieve that or is there a better option to do the same.
One more thing iam realising here is that iam going to use this same data in very many applications and some one from one department is going to enter this data in all these different applications. so i was wondering if there could be a way of having a central database that this guy can mantain and then i be able to use that table data in different applications that iam going to develop. I dont want to kill this unlucky guy with data entry tasks every time i deploy a new application.
So basically, how can make one database application sever several different applications with its data.

View 6 Replies View Related

Large Table-Table Partition, View Or Other Method?

Aug 27, 2007

Hi everyone,

I use sql 2005. What is the best practice for dealing with large table (more than million rows)? Table Partition, View or other?

Can you please give some suggestions? It will be very helpful if you can post some references or examples.

Thank you!

View 12 Replies View Related

Can We Use DTS To Import PDF And MP3 Into SQL Server 200 Table?

Aug 30, 2006

I've got a situation in whcih I have to import PDF and MP3 files into SQL Server 2000 table.

Thanks,

YL

View 7 Replies View Related

Where To Order The Table Values Displayed In A Web Form Object? In Sql Server Or In The Application?

Sep 10, 2004

Hi,

I have a table in my database with several car types, and the order I want for that table is:

Car_typeA_1
Car_typeA_2
Car_typeA_3
Car_typeA_4
Other_Cars_typeA
Car_typeB_1
Car_typeB_2
Car_typeB_3
Other_Cars_typeB
Car_typeC_1
Car_typeC_2
Car_typeC_3
Car_typeC_4
Car_typeC_5
Other_Cars_typeC
...


This table is more or less always the same, but from time to time I want to add a new car type, for instance; Car_typeA_5, but this new type must be located under the last register, in the example under ‘Other_Cars_typeC’. So, now the order is wrong, and when I want to display these car types to a web form object, the items will appear wrong ordered.

My question is: To order the values(items) correctly, Where I have to do it? In the web page (ASP.NET) code behind, or somewhere in SQL Server (for example in the Stored Procedure that passes the value to the application)? Or maybe in the same database table..?

Thank you,
Cesar

View 7 Replies View Related

Send Request To Stored Procedure From A Method And Receive The Resposne Back To The Method

May 10, 2007

Hi,I am trying to write a method which needs to call a stored procedure and then needs to get the response of the stored procedure back to the variable i declared in the method. private string GetFromCode(string strWebVersionFromCode, string strWebVersionString)    {      //call stored procedure  } strWebVersionFromCode = GetFromCode(strFromCode, "web_version"); // is the var which will store the response.how should I do this?Please assist.  

View 3 Replies View Related

Can We Use DTS To Import PDF And MP3 Into SQL Server 2000 Table?

Aug 30, 2006

I've got a situation in whcih I have to import PDF and MP3 files into SQL Server 2000 table.

Thanks,

YL

View 3 Replies View Related

SQL Server 2008 :: Import Table Data From Production To Development Server

Feb 18, 2015

Production and development servers are on different domains and they do not trust each other. How do I import data from the table t1 from a database db1 in production and load it into table t1 inside database db1 in development?

View 3 Replies View Related

Import Outlook/ACT Etc Contacts To SQL Server Table

Feb 3, 2005

Guys
Does anyone know of a 3rd party module/plug-in for VS or even some
downloadable code that enables the import of Outlook/ACT and similar contact
information through an ASP.NET page into a SQL Server table with ongoing
1-click button sync.

I need to replicate something similar to the Intellisync tool used in Yahoo
Mail.

regards
Andy

View 3 Replies View Related

SQL Server 2014 :: Bulk Import XML To Table

Jun 19, 2014

I found loads of things but nothing seems to work...

I'm trying to get a link with XML data inside the page into a table but I can't find anything

View 9 Replies View Related

Import Excel Data To A Sql Server Table

Sep 11, 2007

Hi,

I need to import data from more than 10 excels having the same format in to a single sql server table.

I tried to use

INSERT INTO MyTempTable
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 11.0;Database=C:Book1.xls', [Sheet1$])

but got the below error
Ad hoc access to OLE DB provider 'Microsoft.Jet.OLEDB.4.0' has been denied. You must access this provider through a linked server.

If DTS package is used then I am not sure how I can place 10 excels at a time so that they can be picked one by one and data is imported in to table.

Please help.

Thanks,
Vimalraj

View 1 Replies View Related

T-SQL: Import Excel List Into SQL Server Table

Jan 8, 2008

Hi everyone!

I asked a similar question like this yesterday but i didnt work the way I wanted it to work. So I will ask in a diffrent way:

I have an Excel list which i want to import into a table in my SQL Server 2005. The ServerTable has one more column (for the the primary key which is created automatically) than the ExcelList. How can i import the ExcelList in a way so that I the first column of my ServerTable is not filled by a column of my ExcelList??

That is how far I came:

select *
into SQLServerTable FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D: esting.xls;HDR=YES',
'SELECT * FROM [Sheet1$]')


many thanks and greetings from austria

landau

View 3 Replies View Related

Moving One Table From One Server To Another Server Using Import/export?

Mar 18, 2008

I have two databases on two different servers (an old hosting solution and a new). I need to get all the data from one server to the other but I have no clue as how to do it with MS SQL Server Management Studio Express.

I can easily make the create table scripts that will allow me to create the tables on the new server but what about all the data. I wondered if there is some way to export and import data from one server to another?

With the old SQL Enterprise Manager I was able to import or export as I saw fit but I can't seem to find anything like this with the express manager.

Anyone has any advise as I would like to avoid coding somekind of export program myself,


Many kind regards

Weinreich

View 3 Replies View Related

[Table Partitioning] What Is The Best Method?

Oct 11, 2006

Hello,

I have a Sql Server 2005 database with many tables, each with millions of records within them.

They all have a Receive Date field, with records going back 10 years or so.

What would be the best way to partition it? I was thinking of partitioning them by years, but that would give me 10+ partitions -- would that be alot of overhead?

~Le

View 2 Replies View Related

Table FillSchema Method

Oct 21, 2006

Hi,

Sorry if these is not the right forum for this:

I€™m using the data adapter method FillSchema works fine in MS Access but SQL Server Express Edition it doesn€™t get the primary key of the table. For example if I try to use the Find method of the dataset I get this error €œTable doesn't have a primary key€? but in MS Access these do not happen.

This is the code that I€™m using:
Dim sql As String = "SELECT admin.rents.id, admin.rents.transaction_id, admin.rents.item_id, admin.rents.description, admin.rents.due_date, admin.rents.return_date, "
sql &= "admin.rents.amount_to_pay, admin.rents.paid_amount, admin.rents.tax, admin.rents.type, admin.rents.deposit_id "
sql &= "FROM admin.rents INNER JOIN "
sql &= "admin.transactions ON admin.rents.transaction_id = admin.transactions.id "
sql &= "WHERE admin.transactions.customer_id=?; "

RentsDA = New OdbcDataAdapter(sql, cn)
With RentsDA.SelectCommand
.Parameters.Add(New OdbcParameter("@customer_id", OdbcType.Int)).Value = TextBox1.Text.Trim
End With
RentsDA.FillSchema(ds, SchemaType.Source, "Rents")
RentsDA.Fill(ds, "Rents")

It's because of the joins?
I need to configure something in the sql server?
What is the problem?

View 1 Replies View Related

Import Text File To Sql Table In Sql Server 2005

Mar 7, 2008

hi guys
i need  to import text file to sql table in sql server 2005 ...using query how do i import text file to sql table .......................
 i need query
i dont want go Import/export options

View 1 Replies View Related

VB Code To Export And Import SQL Server Table To Oracle

Jan 29, 2008

Hi,

Please do anyone know a VB 2005 code to export and import SQL server table to Oracle. Thanks.

View 3 Replies View Related

Quickest Method Of Updating A Table

Feb 9, 2007

I have a DataSet which I am holding in .NET and I would like to know the quickest way to get the DataSet in to a Table on SQL Server?
Any sample code would be great.

View 6 Replies View Related

Passing Table Name To The Openxml Method

Jul 8, 2007

I want to pass the table name as a variable

Declare @tbl varchar(30)
set @tbl = 'DB.dbo.Set'
declare @sql nvarchar(200)
set @sql =
'select * from OPENXML(@xmldoc,'DB.dbo.Site',2) with' + @tbl + ''
exec(@sql)

Please help me with the correct syntax.
Mayank

View 1 Replies View Related

How To Use Inner Join In Update Method For 1 Table

Aug 23, 2007

i need to use inner join while updating..
im using only one table..


rajesh

View 2 Replies View Related

Update Method Is Not Finding A Nongeneric Method!!! Please Help

Jan 29, 2008

Hi,
 I just have a Dataset with my tables and thats it
 I have a grid view with several datas on it
no problem to get the data or insert but as soon as I try to delete or update some records the local machine through the same error
Unable to find nongeneric method...
I've try to create an Update query into my table adapters but still not working with this one
Also, try to remove the original_{0} and got the same error...
 Please help if anyone has a solution
 
Thanks

View 7 Replies View Related

Sql Server 2005 Express: Export/Import Content Of A Table

Apr 3, 2008

 I want to export data in a table from one database to another database. And I would like it bo be clone of the source table, if it's possible. Is there any tools out there that can help me with this or do I have to write my own code?Is it possible to query the database to get all columns and datatypes for Ã¥ requested table? If possible, can you give me an example?If I have to write a tool myself I guess I would do something like this: Export - Query the database for columns and datatype for the requested table. Dynamically generate a query to retrieve all rows from the table and save it to an xml file. Import - Turn off the Identity Increment, loop through the xml file and generate insert queries to insert a clone of each row, turn off the Identity Increment. Viola! If programming only could be that simple :-) Regards, Sigurd 

View 5 Replies View Related

DTS Import Problem With Text Datatype From SQL Server To MySQL Table

Dec 29, 2003

Can anybody tell how to import a table with the text column from SQL Server 2000 to MySQL 4.0.17?
I tried this using ODBC connection but got an error message saying, "Query-based Insertion or updating of BLOB values is not supported".

View 9 Replies View Related

SQL Server 2012 :: Import Data From HTML Document Into Table

Oct 8, 2014

I have someone who is sending me .htm documents, with a table in them, and I was wondering if there is a way to import the data from those tables into a SQL table, probably using an SSIS Package.

View 4 Replies View Related

Integration Services :: Import Data Form One Table To Another Server

May 27, 2015

import data form one table to another.Both table have different schema.Lets say

1. Employee(Empid, ename,address,designation,Joindate,DOB).
2.Person(name,address,DOB)

I need to import person table data into Employee table.

Note :

1 empid is auto increment
2. If Person.DOB is not present insert null into employee.DOB
3.JoinDate should be initialized with current date. 

Currently I am using

1.OLE DB Source
2.Data Conversion
3.OLE DB Destination.

View 11 Replies View Related

Easier Method To Remove And Add A Table To Database?

Feb 22, 2000

I have a table that is corrupted and want to remove and add a backup version of it. How can i remove this table and add it again preserving all the foregin key restraints, permissions, dependencies, etc? Simply exporting and importing does not work. I could painfully remove the table and then painfully reconnect it again, recreating all the foreign key restraints, etc, by hand; but there has to be an easier way! What is the How-to?

Thank you!

Llyal

View 1 Replies View Related

Seek Method, Table-direct, And Sql Server2005

Jul 23, 2005

From what I've read in the docs, ado.net currently supports opening sqlserver ce tables in table-direct mode and performing Seek operations on them(using SqlCeDataReader), but not on the full-blown sql server. Is this(will this be) still true with ado.net 2.0 & sql server 2005?

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved