This is a multi-part message in MIME format.

------=_NextPart_000_00B3_01C4653C.BD93F510
Content-Type: text/plain;
charset="windows-874"
Content-Transfer-Encoding: quoted-printable

Dear all=20

I use it - 6000 and i import text file about 300 rec but it use 20 =
sec. how can i develop fast than this code . help me too.

Best Reg.
TingNong


Private Sub cmdImport_Click(ByVal sender As System.Object, ByVal e As =
System.EventArgs) Handles cmdImport.Click

Dim FileName As String

Dim FullFileName As String

On Error GoTo Err

OpenFileDialog1.Filter =3D "Text File|*.txt"

OpenFileDialog1.ShowDialog()

Application.DoEvents()

If Trim(OpenFileDialog1.FileName) =3D "" Then

Exit Sub

End If

FileName =3D System.IO.Path.GetFileName(OpenFileDialog1.FileName)

FullFileName =3D OpenFileDialog1.FileName

ShopId =3D Mid(FileName.Trim, 2, 4)

Dim Sr As New System.IO.StreamReader(FullFileName)

Dim line As String

Dim Da As SqlCeCommand =3D New SqlCeCommand

Dim Strsql As String

Dim Barcode As String

Dim Pro_Name As String

Dim Pro_Code As String

Dim Size As String

Dim Color As String

Dim Qty As Integer

Dim Point As Integer

Dim Col As Integer

Dim Rec As Single

Dim mRec As Single

' Read and display the lines from the file until the end=20

' of the file is reached.

' Delete All Data

Strsql =3D "Delete From MasterBC Where ShopId =3D '" & Trim(ShopId) & =
"'"

Da.Connection =3D Conn

Da.CommandText =3D Strsql

Da.ExecuteNonQuery()

Strsql =3D "Delete From SubMaster Where ShopId =3D '" & Trim(ShopId) & =
"'"

Da.Connection =3D Conn

Da.CommandText =3D Strsql

Da.ExecuteNonQuery()

Rec =3D 0

recProcess =3D 0

Timer1.Enabled =3D True

lblProcess.Visible =3D True

lblRec.Visible =3D True

Do While Sr.Peek() >=3D 0

line =3D Sr.ReadLine()

Col =3D 0

Do Until InStr(line, ",") =3D 0

Point =3D InStr(line, ",")

If Point =3D 0 Then

Qty =3D line

Else

Col =3D Col + 1

Select Case Col

Case 1

Barcode =3D Mid(line, 1, Point - 1)

Case 2

Pro_Name =3D Mid(line, 1, Point - 1)

Case 3

Pro_Code =3D Mid(line, 1, Point - 1)

Case 4

Size =3D Mid(line, 1, Point - 1)

Case 5

Color =3D Mid(line, 1, Point - 1)

End Select

line =3D Mid(line, Point + 1, Len(line))

If InStr(line, ",") =3D 0 Then

Qty =3D line

End If

End If

Sr.Peek()

Loop

' =E0=BE=D4=E8=C1=A2=E9=CD=C1=D9=C5=E3=B9 Table Master

Strsql =3D "Insert Into =
MasterBC(ShopId,Barcode,ProductName,ProductCode,Size,Color,Qty) " & _

" Values('" & ShopId & "','" & Trim(Barcode) & "','" & Trim(Pro_Name) & =
"'," & _

" '" & Trim(Pro_Code) & "','" & Trim(Size) & "','" & Trim(Color) & "'," =
& _

" " & Qty & ")"

Da.Connection =3D Conn

Da.CommandText =3D Strsql

Da.ExecuteNonQuery()

Strsql =3D "Insert Into SubMaster(ShopId,Barcode,Qty) " & _

" Values('" & Trim(ShopId) & "','" & Trim(Barcode) & "',0)"

Da.Connection =3D Conn

Da.CommandText =3D Strsql

Da.ExecuteNonQuery()

'Rec =3D Rec + 1

recProcess =3D recProcess + 1

Application.DoEvents()

Loop

lblProcess.Text =3D ""

lblRec.Text =3D ""

lblProcess.Visible =3D False

lblRec.Visible =3D False

Timer1.Enabled =3D False

Sr.Close()



MessageBox.Show("Import Complete")

Exit Sub

Err:

MessageBox.Show(Err.Number & " " & Err.Description)

End Sub

------=_NextPart_000_00B3_01C4653C.BD93F510
Content-Type: text/html;
charset="windows-874"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-874">
<META content=3D"MSHTML 6.00.3790.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Dear all </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; I use it - 6000 and =
i import=20
text file about 300 rec but it use 20 sec. how can i develop fast =
than&nbsp;=20
this code . help me too.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Best Reg.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>TingNong</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>
<P><FONT face=3DArial size=3D2>Private Sub cmdImport_Click(ByVal sender =
As=20
System.Object, ByVal e As System.EventArgs) Handles =
cmdImport.Click</FONT></P>
<P><FONT face=3DArial size=3D2>Dim FileName As String</FONT></P>
<P><FONT face=3DArial size=3D2>Dim FullFileName As String</FONT></P>
<P><FONT face=3DArial size=3D2>On Error GoTo Err</FONT></P>
<P><FONT face=3DArial size=3D2>OpenFileDialog1.Filter =3D "Text =
File|*.txt"</FONT></P>
<P><FONT face=3DArial size=3D2>OpenFileDialog1.ShowDialog()</FONT></P>
<P><FONT face=3DArial size=3D2>Application.DoEvents()</FONT></P>
<P><FONT face=3DArial size=3D2>If Trim(OpenFileDialog1.FileName) =3D ""=20
Then</FONT></P>
<P><FONT face=3DArial size=3D2>Exit Sub</FONT></P>
<P><FONT face=3DArial size=3D2>End If</FONT></P>
<P><FONT face=3DArial size=3D2>FileName =3D=20
System.IO.Path.GetFileName(OpenFileDialog1.FileName)</FONT></P>
<P><FONT face=3DArial size=3D2>FullFileName =3D =
OpenFileDialog1.FileName</FONT></P>
<P><FONT face=3DArial size=3D2>ShopId =3D Mid(FileName.Trim, 2, =
4)</FONT></P>
<P><FONT face=3DArial size=3D2>Dim Sr As New=20
System.IO.StreamReader(FullFileName)</FONT></P>
<P><FONT face=3DArial size=3D2>Dim line As String</FONT></P>
<P><FONT face=3DArial size=3D2>Dim Da As SqlCeCommand =3D New =
SqlCeCommand</FONT></P>
<P><FONT face=3DArial size=3D2>Dim Strsql As String</FONT></P>
<P><FONT face=3DArial size=3D2>Dim Barcode As String</FONT></P>
<P><FONT face=3DArial size=3D2>Dim Pro_Name As String</FONT></P>
<P><FONT face=3DArial size=3D2>Dim Pro_Code As String</FONT></P>
<P><FONT face=3DArial size=3D2>Dim Size As String</FONT></P>
<P><FONT face=3DArial size=3D2>Dim Color As String</FONT></P>
<P><FONT face=3DArial size=3D2>Dim Qty As Integer</FONT></P>
<P><FONT face=3DArial size=3D2>Dim Point As Integer</FONT></P>
<P><FONT face=3DArial size=3D2>Dim Col As Integer</FONT></P>
<P><FONT face=3DArial size=3D2>Dim Rec As Single</FONT></P>
<P><FONT face=3DArial size=3D2>Dim mRec As Single</FONT></P>
<P><FONT face=3DArial size=3D2>' Read and display the lines from the =
file until the=20
end </FONT></P>
<P><FONT face=3DArial size=3D2>' of the file is reached.</FONT></P>
<P><FONT face=3DArial size=3D2>' Delete All Data</FONT></P>
<P><FONT face=3DArial size=3D2>Strsql =3D "Delete From MasterBC Where =
ShopId =3D '"=20
&amp; Trim(ShopId) &amp; "'"</FONT></P>
<P><FONT face=3DArial size=3D2>Da.Connection =3D Conn</FONT></P>
<P><FONT face=3DArial size=3D2>Da.CommandText =3D Strsql</FONT></P>
<P><FONT face=3DArial size=3D2>Da.ExecuteNonQuery()</FONT></P>
<P><FONT face=3DArial size=3D2>Strsql =3D "Delete From SubMaster Where =
ShopId =3D '"=20
&amp; Trim(ShopId) &amp; "'"</FONT></P>
<P><FONT face=3DArial size=3D2>Da.Connection =3D Conn</FONT></P>
<P><FONT face=3DArial size=3D2>Da.CommandText =3D Strsql</FONT></P>
<P><FONT face=3DArial size=3D2>Da.ExecuteNonQuery()</FONT></P>
<P><FONT face=3DArial size=3D2>Rec =3D 0</FONT></P>
<P><FONT face=3DArial size=3D2>recProcess =3D 0</FONT></P>
<P><FONT face=3DArial size=3D2>Timer1.Enabled =3D True</FONT></P>
<P><FONT face=3DArial size=3D2>lblProcess.Visible =3D True</FONT></P>
<P><FONT face=3DArial size=3D2>lblRec.Visible =3D True</FONT></P>
<P><FONT face=3DArial size=3D2>Do While Sr.Peek() &gt;=3D 0</FONT></P>
<P><FONT face=3DArial size=3D2>line =3D Sr.ReadLine()</FONT></P>
<P><FONT face=3DArial size=3D2>Col =3D 0</FONT></P>
<P><FONT face=3DArial size=3D2>Do Until InStr(line, ",") =3D =
0</FONT></P>
<P><FONT face=3DArial size=3D2>Point =3D InStr(line, ",")</FONT></P>
<P><FONT face=3DArial size=3D2>If Point =3D 0 Then</FONT></P>
<P><FONT face=3DArial size=3D2>Qty =3D line</FONT></P>
<P><FONT face=3DArial size=3D2>Else</FONT></P>
<P><FONT face=3DArial size=3D2>Col =3D Col + 1</FONT></P>
<P><FONT face=3DArial size=3D2>Select Case Col</FONT></P>
<P><FONT face=3DArial size=3D2>Case 1</FONT></P>
<P><FONT face=3DArial size=3D2>Barcode =3D Mid(line, 1, Point - =
1)</FONT></P>
<P><FONT face=3DArial size=3D2>Case 2</FONT></P>
<P><FONT face=3DArial size=3D2>Pro_Name =3D Mid(line, 1, Point - =
1)</FONT></P>
<P><FONT face=3DArial size=3D2>Case 3</FONT></P>
<P><FONT face=3DArial size=3D2>Pro_Code =3D Mid(line, 1, Point - =
1)</FONT></P>
<P><FONT face=3DArial size=3D2>Case 4</FONT></P>
<P><FONT face=3DArial size=3D2>Size =3D Mid(line, 1, Point - =
1)</FONT></P>
<P><FONT face=3DArial size=3D2>Case 5</FONT></P>
<P><FONT face=3DArial size=3D2>Color =3D Mid(line, 1, Point - =
1)</FONT></P>
<P><FONT face=3DArial size=3D2>End Select</FONT></P>
<P><FONT face=3DArial size=3D2>line =3D Mid(line, Point + 1, =
Len(line))</FONT></P>
<P><FONT face=3DArial size=3D2>If InStr(line, ",") =3D 0 Then</FONT></P>
<P><FONT face=3DArial size=3D2>Qty =3D line</FONT></P>
<P><FONT face=3DArial size=3D2>End If</FONT></P>
<P><FONT face=3DArial size=3D2>End If</FONT></P>
<P><FONT face=3DArial size=3D2>Sr.Peek()</FONT></P>
<P><FONT face=3DArial size=3D2>Loop</FONT></P>
<P><FONT face=3DArial size=3D2>' =E0=BE=D4=E8=C1=A2=E9=CD=C1=D9=C5=E3=B9 =
Table Master</FONT></P>
<P><FONT face=3DArial size=3D2>Strsql =3D "Insert Into=20
MasterBC(ShopId,Barcode,ProductName,ProductCode,Size,Color,Qty) " &amp;=20
_</FONT></P>
<P><FONT face=3DArial size=3D2>" Values('" &amp; ShopId &amp; "','" =
&amp;=20
Trim(Barcode) &amp; "','" &amp; Trim(Pro_Name) &amp; "'," &amp; =
_</FONT></P>
<P><FONT face=3DArial size=3D2>" '" &amp; Trim(Pro_Code) &amp; "','" =
&amp;=20
Trim(Size) &amp; "','" &amp; Trim(Color) &amp; "'," &amp; _</FONT></P>
<P><FONT face=3DArial size=3D2>" " &amp; Qty &amp; ")"</FONT></P>
<P><FONT face=3DArial size=3D2>Da.Connection =3D Conn</FONT></P>
<P><FONT face=3DArial size=3D2>Da.CommandText =3D Strsql</FONT></P>
<P><FONT face=3DArial size=3D2>Da.ExecuteNonQuery()</FONT></P>
<P><FONT face=3DArial size=3D2>Strsql =3D "Insert Into =
SubMaster(ShopId,Barcode,Qty) "=20
&amp; _</FONT></P>
<P><FONT face=3DArial size=3D2>" Values('" &amp; Trim(ShopId) &amp; =
"','" &amp;=20
Trim(Barcode) &amp; "',0)"</FONT></P>
<P><FONT face=3DArial size=3D2>Da.Connection =3D Conn</FONT></P>
<P><FONT face=3DArial size=3D2>Da.CommandText =3D Strsql</FONT></P>
<P><FONT face=3DArial size=3D2>Da.ExecuteNonQuery()</FONT></P>
<P><FONT face=3DArial size=3D2>'Rec =3D Rec + 1</FONT></P>
<P><FONT face=3DArial size=3D2>recProcess =3D recProcess + 1</FONT></P>
<P><FONT face=3DArial size=3D2>Application.DoEvents()</FONT></P>
<P><FONT face=3DArial size=3D2>Loop</FONT></P>
<P><FONT face=3DArial size=3D2>lblProcess.Text =3D ""</FONT></P>
<P><FONT face=3DArial size=3D2>lblRec.Text =3D ""</FONT></P>
<P><FONT face=3DArial size=3D2>lblProcess.Visible =3D False</FONT></P>
<P><FONT face=3DArial size=3D2>lblRec.Visible =3D False</FONT></P>
<P><FONT face=3DArial size=3D2>Timer1.Enabled =3D False</FONT></P>
<P><FONT face=3DArial size=3D2>Sr.Close()</FONT></P>
<P><FONT face=3DArial size=3D2></FONT>&nbsp;</P>
<P><FONT face=3DArial size=3D2>MessageBox.Show("Import =
Complete")</FONT></P>
<P><FONT face=3DArial size=3D2>Exit Sub</FONT></P>
<P><FONT face=3DArial size=3D2>Err:</FONT></P>
<P><FONT face=3DArial size=3D2>MessageBox.Show(Err.Number &amp; " " =
&amp;=20
Err.Description)</FONT></P>
<P><FONT face=3DArial size=3D2>End Sub</FONT></P></DIV></BODY></HTML>

------=_NextPart_000_00B3_01C4653C.BD93F510--