Total members 11895 |It is currently Tue Dec 03, 2024 5:54 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





HI...

I'm new in asp.net, I get a problem when import a file text file to
database sql server wtih asp.net, here the sample of the text file

Code:
0618888888 KURNIA SEMARANG 86 63360
0619999999 HIAPEE WAHIDIN 105 95664

i get a problem when split those records.

here is my script :
Code:
Dim strcontenttype FileUpload1.PostedFile.ContentType
Dim ms 
As New System.IO.StreamReader
(FileUpload1.PostedFile.InputStream)
Dim strResult As String ms.ReadToEnd()

Dim recStr() As String strResult.Split("vbcrlf")
Dim recItem As String ""
Dim nLoop As Integer 0
Dim arRec
(recStr.Length) As MyRecord



Dim nt 
As String
Dim nm 
As String
Dim kt 
As String
Dim id 
As String
Dim nom 
As Decimal

For nLoop 0 To recStr.Length 1
recItem 
recStr(nLoop)
If 
recItem.Length 106 Then
nt 
recItem.Substring(014)
nm recItem.Substring(1523)
kt recItem.Substring(2438)
id recItem.Substring(3953)
nom CType(recItem.Substring(54), Decimal)
Dim command As SqlCommand
Dim connection 
As New SqlConnection("Data
Source=xxx;Initial Catalog=xxxx;User ID=xxx; password=xxxx"
)
command connection.CreateCommand
command
.CommandText "INSERT INTO xxxx
(aaa,bbb,ccc,ddd,eeee) VALUES ('" 
recItem.Substring(014) & "','"
recItem.Substring(1523) & "','" recItem.Substring(2438)
"','" recItem.Substring(3953) & "','" CType(recItem.Substring
(54), Decimal) & "')"
connection.Open()
command.ExecuteNonQuery()
connection.Close()
End If
Next


Please help me how to read those record please:)




Author:
Proficient
User avatar Posts: 280
Have thanks: 1 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Import text file with ASP.NET
 import XSD file in another     -  
 Create a text file     -  
 Read Arabic text from file     -  
 display the content of text file     -  
 Reading and Writing To text file     -  
 Search records from text file     -  
 uploading text file to java program     -  
 the text file i saved all in one line. How can i solve it?     -  
 Static Import     -  
 import Mysql database     -  



Topic Tags

ASP Files and I/O






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com