.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

import text to database

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :Sql Server


I have a text file that looks like this:
Chapter 1
Line 1: some text here some text here
Line 2: some text here some text here
Line 3: some text here some text here

Chapter 2
Line 1: some text here some text here
Line 2: some text here some text here
Line 3: some text here some text here

I want to import this into a database so that the table will look something like this:
Chapter, Line, Text
1,1,some text here some text here
1,2,some text here some text here
1,3,some text here some text here
2,1,some text here some text here
2,2,some text here some text here
I guess I need to wrote some custom C#/VB code to get this done, is this correct or can I use SSIS with / without the custome code.


eddiec :-)

View Complete Post

More Related Resource Links

xml import to database


Hello. I have XML document I use for backups..

I am using this code for importing XML to database:

protected void uvoziPodatkeXML(string backup, int tabela, string destinacijaTabela)
            DataSet reportData = new DataSet();

            FileStream filestream = File.OpenRead(lblPotIzvozi.Text + txtIme.Text + backup);
            BufferedStream buffered = new BufferedStream(filestream);

            //reportData.ReadXml(lblPotIzvozi.Text + txtIme.Text + backup);

            SqlConnection povezava = new SqlConnection(Convert.ToString(Session["cs"]));
            SqlBulkCopy sbc = new SqlBulkCopy(Convert.ToString(Session["cs"]), SqlBulkCopyOptions.KeepIdentity);
            sbc.DestinationTableName = destinacijaTabela;


But there is a problem when XML file is very large, larger than 50MB, it lasts forever to import to database.. I was searching over google, and saw that datasets are terrible slow for this operation.. I found some other methodes for use, but don't know there are no examples, that could help me.

Did someone work on this before?

thanks, yevgeni

Update Profile Database from text file using BDC



I have a requirement to import the profile properties from a text file in sFTP to update the MOSS Profile Database. The objective is to create a single repository for the Staff Directory in MOSS.

Can I use BDC to connect and update the Profile database?

What is the alternate approach?


Import Multiple Text Files

I have 150 data delimited text files that need to be imported to a text file. Each of them is named for the table for which they contain data e.g. address.txt contains data that needs to imported to the address table. So what I have done is create a SSIS package that contains a ForEach loop that iterates through the the files, and has a Load Data field object. What I haven't been able to figure out is what logic needs to be added for the Data Flow. I know I will need a Flat File Source with a connection source that is tied to file it is processing.  However, after all of that I am not sure what do because each text file contains a different table with different columns. Can someone explain to me how to handle this? Thanks, Isaiah 

how to check the data which i passesd in text box for logine is available in the database or not.

Hi, I created login form in which ---Username, Password & LogOnType is there, When i m passing the correct value i m login successfully. But instead of entering correct value when i m entering wrong values and clicking SignIN its gives the exception. If i m not entering any value in text box and clicking SignIn its ask for values..................................... How i will make the validation which will check the textbox data which i entered there is correct or not. I want error  msg when data not in the database.........................if data in database then successfully logedIn msg.............   please help me ..............................try to give one example with code if possible   Thanku  

Text truncated to 255 using SSIS ACE.oledbprovider to import excel 2007 spreadsheet

Hi All, Trying to use SSIS SQL 2005 to import an Excel 2007 file (.xlsx). I'm using Office 12.0 Access Database Engine OLEDB Provider with extended properties Excel 12.0;HDR=Yes;IMEX=1 The problem is when I have text with more than 255 characters. It basically defaults the source output to Unicode string[DT_WSTR] 255, If I change it it errors out. I have done the registry change according to http://msdn.microsoft.com/en-us/library/ms141683.aspx but I think it only applies to Excel source not OleDb Source. (A Excel source does give me a text instead of string )   I have also tried to increasing the length of output such as 4000 instead of 255 but it doesn't allow either.   Anybody can help?I'm stuck for a day. Thank you very much for your help. Regards, Koala  

Why is it that this code updates my sql database with the default EditBox text?

Any help is appreciated. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using MySql.Data.MySqlClient; public partial class _Default : System.Web.UI.Page { TextBox EditBox = new TextBox(); TableRow[] NewRows = { new TableRow(), new TableRow() }; TableCell[] NewCells = { new TableCell(), new TableCell() }; string ID; protected void Page_Init(object sender, EventArgs e) { } protected void Page_Load(object sender, EventArgs e) { var Connection = new MySqlConnection("Server=localhost;Database=site;Username=root;Password=root"); var Command = new MySqlCommand("select * from news", Connection); Connection.Open(); var Reader = Command.ExecuteReader(); while (Reader.Read()) { ID = Reader.GetString("ID"); string Title = Reader.GetString("Title"); string Text = Reader.GetString("Text"); foreach (TableRow Row in NewRows) { NewsTable.Rows.Add(Row); } NewCells[0].Text = Title; NewCells[1].Text = Text; NewCells[0].Font.Bold = true; NewCells[0].Font.Underline = true; NewCells[0].Font.Size = Fon

How to create a SSIS package to import records form SQl Server 2008 tables to text files

I am a newbie to SSIS and would like to create a package to accomplish the task referenced in the above title. Will appreciate any links and pointers in the right direction.   Thanksakoranteng

how to import a database from sql 2008 r2 to sql 2008 ( from 10.50.1600 to 10.0.2531.0)

Hi I wolud like to import a database from sql 2008 r2 to sql 2008. I have got an error: This version is incompatible with that server. Microsoft SQL Server Management Studio      10.0.2531.0 Microsoft Analysis Services-Clienttools      10.0.1600.22 Microsoft Data Access Components (MDAC)      6.1.7600.16385 Microsoft MSXML      3.0 6.0 Microsoft Internet Explorer      8.0.7600.16385 Microsoft .NET Framework      2.0.50727.4927 Betriebssystem      6.1.7600 Thanks in advance Sebatian

import a database from sql 2008 r2 to sql 2008.

Hi I wolud like to import a database from sql 2008 r2 to sql 2008. I have got an error: This version is incompatible with that server. Microsoft SQL Server Management Studio      10.0.2531.0 Microsoft Analysis Services-Clienttools      10.0.1600.22 Microsoft Data Access Components (MDAC)      6.1.7600.16385 Microsoft MSXML      3.0 6.0 Microsoft Internet Explorer      8.0.7600.16385 Microsoft .NET Framework      2.0.50727.4927 Betriebssystem      6.1.7600 Thanks in advance Sebatian

Only show text from database if field is not empty

 Hoping someone can help. I am using ASP.NET VB and i am wondering how to only show text from database if data exists. I tried this but it does not work.Any help would be greatly appreciated.I am new to .NET, in the past i have always used classic asp. 1 <td valign="top" style="border-right: 2px solid #031992"> 2 (<%# Eval("VenderPhone1") %>) <%# Eval("VenderPhone2") %>- <%#Eval("VenderPhone3")%> 3 4 <% If String.IsNullOrEmpty(Trim("VenderAlt1").ToString) Then%> 5 <br />(<%#Eval("VenderAlt1")%>) <%# Eval("VenderAlt2") %>- <%#Eval("VenderAlt3")%> 6 <% End If%> 7 <% If String.IsNullOrEmpty(Trim("VenderFax1").ToString) Then%> 8 <br />(<%# Eval("VenderFax1") %>) <%# Eval("VenderFax2") %>- <%#Eval("VenderFax3")%> 9 <% End If%> 10 11 </td> 12   

Unable to see Active Directory Groups in the User Profile Database after Profile Import

SharePoint Server 2010 Enterprise RTM. W2K8R2 w/multi-server setup: AD/DNS SQL 2008 WFE APP Claims Mode Web App only using Windows Integrated Auth So, this was never a problem in 2007, and I didn't even realize it was a problem in 2010 until I started to build a solution that utilized my blog article: InfoPath - User Roles in Browser-Enabled Forms Using AD Groups.  I went to utilize the same web method of the same web service, but I noticed that no data was showing up at all.  Typically, the GetUserMembership/GetCommonMembership methods return the specified user's memberships: AD Security Groups, AD Distribution Lists, and SharePoint Sites (not SharePoint Groups, though). My user profile sync is working.  All AD users are pulled in with the proper profile data. "Users and Groups" is selected in the Synchronization Entities section of my Sync Settings. Security groups are working for permissions and audience targeting.  Confirmed my users are affected properly by the use of Security Groups. My query to the GetUserMemberships web method (and GetCommonMemberships) is running (not failing), but it's not returning anything even though my user is in some Security Groups and has explicit membership to multiple sites. The GetUserProfileByName method of the same UserProfileService.asmx web service returns all the regular profile data

Need help with uploading a text file in to mysql database


I want to upload a text file and stored to my database. the column on my database it is longblob type. I don't know much about this so if anyone can help I will thank you. 

Text was truncated with "nvarchar(max)" data type and size by using SSIS Import and Export Wizar



I am using SSIS Import and export Wizar to load data from Excel file, I have set the datatype as "nvarchar(max); those data are not biger than 1000 bits but was failed to transfer as the error says:

[Source - TreatmentPlans$ [1]] Error: The "output column "SchoolPlan" (57)" failed because truncation occurred, and the truncation row disposition on "output column "SchoolPlan" (57)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.

Correct Way to Insert Data from Text Boxes on ASPX page into SQL Database Using VB


Please help me, I have been trying this for a week now and this is how far I have gotten.


I am new to this, and I am using MS Visual Web Developer Express.


OK - This is what I have come up with, but when I run it I get the following error  (I decided to just try to use a simplified table just to get an understanding of the basic concepts):



Partial Class label_form
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' Declaring variables
        Dim username, labelname, ownersname, address1, address2, city, state, zipcode, country, contactnumber, emailaddress, data_source, con, sql_insert

        ' Check if Necessary Text Is Missing ( will do this once I can get it to work with no empty text boxes)

        ' Get Values from TextBoxes
        username = txtUserName.Text
        labelname = txtLabelName.Text
        ownersname = txtOwnersName

How to save WPF RichTextBox content (text + image) to the database



I want to save (and after that also to retrieve) the content of an WPF RichTextBox (text + image) to/from the database.

I found this: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/750a654e-b002-4742-8f46-609e93f6ec81 but like the author said, the solution seams not to work for text with image - the image is ignored/removed and only the formatted text is saved and after that retrieved to/from database.

Know someone a solution about this issue?

Best regards,





Import values from a text.txt file



I've tried with searching google for what i need, I have a textfile with value below, how can i pick values and then insert into db table

ABI 95035345         0000016281400000113970000001139700000000000008770230000     ST  00053215/65R16TL 98TRBL


so for example I would like to import char from left

Start    End

4           8

22        28

and so on

Can someone put me on the right path




is it possible to import data into a replicated database


I have a 2005 database set up Ok for Merge replicataion and I need to add data from an Acess 97 database I have been using the wizard to import the tables to new tables then I have a script which appends the tables sometimes making small changes this is fine if the database is not replicable but will not work if it is.  I do need to keep all identiy fields
Some of these tables only have a couple of rows and their 'range' seems to be within the values in the table properties

I get error
The insert failed. It conflicted with an identity range check constraint in database 'My_MPC', replicated table 'dbo.TblLiqItems', column 'LiqId'. If the identity column is automatically managed by replication, update the range as follows: for the Publisher, execute sp_adjustpublisheridentityrange; for the Subscriber, run the Distribution Agent or the Merge Agent.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend