| | |
Upload txt data to MS SQL Database (Using C# and ASP.NET)
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
Can you Post your TextFile and a Create Script of your SQl Table and i will give you an Exact code to write.
kind Regards
Vuyiswa Maseko
kind Regards
Vuyiswa Maseko
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
•
•
Join Date: May 2009
Posts: 40
Reputation:
Solved Threads: 0
C# Syntax (Toggle Plain Text)
CREATE TABLE mytable ( /*id INT IDENTITY(1,1) PRIMARY KEY,*/ Fname text, Surname text, Tel text, Salary DECIMAL(18,2) );
text file:
Hein|Oosthuyzen|0123313470|15489.62
Johan|du Toit|0126547896|13240.27
Nico|Fourie|0124784532|14500.20
Shaun|Venter|0123546987|16320.12
Burnabe|Jordaan|0124872134|12480.80
Here is your Solution
Kind Regards
Vuyiswa
C# Syntax (Toggle Plain Text)
SqlConnection con =new SqlConnection(@"User id=sa;Password=oops;Server=VUYISWA\SQLEXPRESS;Database=Vuyiswa"); SqlCommand cmdinsert = new SqlCommand(); cmdinsert.CommandText=@"BULK INSERT mytable FROM 'C:\WebSite29\Data.txt' WITH (FIELDTERMINATOR = '|', ROWTERMINATOR = '\n' );"; cmdinsert.CommandTimeout = 0; cmdinsert.CommandType= CommandType.Text; cmdinsert.Connection = con; try { con.Open(); cmdinsert.ExecuteNonQuery(); } catch(SqlException ex) { Label1.Text = ex.Message.ToString(); } finally { if(con != null) { con.Close(); } }
Kind Regards
Vuyiswa
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
No Problem and dont Forget to mark the post as resolved and give me my reputation. am going home now enjoy your weekend
Kind Regards
Vuyiswa Maseko
Kind Regards
Vuyiswa Maseko
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
•
•
Join Date: Jul 2009
Posts: 969
Reputation:
Solved Threads: 207
•
•
•
•
Sorry i thought it worked but i see now that i still can't have a autonumber column in my database...? the bulk insert works from the first column onwards and i need to have the autonumber column...Any further suggestions?
![]() |
Similar Threads
- How to connect MSAccess database in ASP.NET (C#)
- add nodes and subnodes to a treeview from sql database by coding in asp.net 2.0 (ASP.NET)
- retrieve data from SQL database into a combobox (Visual Basic 4 / 5 / 6)
- Upload/download file from to SQL Database (C#)
- Upload/download file from to SQL Database (ASP.NET)
- Enable only one user to edit a row in SQL server database using C#, asp.net win apps (ASP.NET)
- need help with sql database in asp.net using VB (ASP.NET)
- How to connect sql database in asp.net using VB? (ASP.NET)
- tool for converting java/sql codes to asp.net/sqol2000 (Java)
Other Threads in the C# Forum
- Previous Thread: sending mail
- Next Thread: C#.net Modifying XML Attribute
| Thread Tools | Search this Thread |
Tag cloud for c#, sql, uploadatextfile
.net access advice ajax array asp asp.net autosuggest buttons c# c++ camera chat combobox connection console convert data database datagridview datastructure datetime degrees developer development drawing dropdown e-commerce editor error excel exectuable file forloop form gdi+ httpwebrequest images index inline java javascript keypress linux list listbox location login math mdd microsoft ms msdn multiple mysql news notepad number office operator oracle password photoshop php picturebox post programming query read remote remoting report resource richtextbox saving security server silverlight software sql sql-injection sql-server sqlserver string tables textbox totaldays treeview vb.net video view vista visualbasic warehouse webbrowser webdevelopemnt winforms working wpf write






