-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: LovedJohnySmith
Message 3 in Discussion
Basically connection object represents a unique session to a SQL Server data
source. In the case of a client/server database system, it is equivalent to a
network connection to the server. SqlConnection is used in conjunction with
DataAdapter and Command to increase performance when connecting to a Microsoft
SQL Server database. If the Connection goes out of scope, it is not closed. if
and if only you explicitly close the connection by calling Close or Dispose.
Please have a look at the following code snippet for bulk insert from CSV.
BULK INSERT pbcr_regn_details_tbl FROM '" & arr & "' WITH ( FIELDTERMINATOR =
',',ROWTERMINATOR = '\n'); Public Sub BulkInsert(arr as String)
Dim CentreCode = session("Centrecode")
Dim DBConn = Application("DBConn")
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim sqlstr as String = "delete from pbcr_regn_details_tbl where cc='" &
CentreCode & "'; delete from pbcr_regn_details_icd10_tbl where cc='" &
CentreCode & "';"
myConnection = New SqlConnection( DBConn )
myConnection.Open()
myCommand = New SqlCommand( sqlstr, myConnection )
myCommand.ExecuteNonQuery()
Try Dim FILENAME as String = arr
Dim objStreamReader as StreamReader
Dim ReadLine as String
Dim SplitString
Dim ProcName
IF ICDCode.SelectedItem.Value = 9 Then
ProcName = " proc_insert_pbcr_regn_details_tbl "
Session("ICDCode") = "9"
Else
ProcName = " proc_insert_pbcr_regn_details_ICD10_tbl "
Session("ICDCode") = "10"
End If
objStreamReader = File.OpenText(FILENAME)
While objStreamReader.Peek() <> -1
ReadLine = objStreamReader.ReadLine()
SplitString = ReadLine.Split(",")
'For i = 0 To Str1.Length() - 1
'Response.Write(Str1(i) & "
")
'Next
IF SplitString.Length() >= 39 Then
sqlstr = "Execute " & ProcName & SplitString(0) & ","
& SplitString(1) & ",'" & SplitString(2) & "'," & SplitString(3) & ",'" &
SplitString(4) & "'," & SplitString(5) & "," & SplitString(5) & "," &
SplitString(7) & "," & SplitString(8) & "," & SplitString(9) & "," &
SplitString(10) & "," & SplitString(11) & "," & SplitString(12) & "," &
SplitString(13) & "," & SplitString(14) & "," & SplitString(15) & "," &
SplitString(16) & "," & SplitString(17) & "," & SplitString(18) & "," &
SplitString(19) & "," & SplitString(20) & "," & SplitString(21) & "," &
SplitString(22) & "," & SplitString(23) & "," & SplitString(24) & ",'" &
SplitString(25) & "'," & SplitString(26) & "," & SplitString(27) & "," &
SplitString(28) & "," & SplitString(29) & "," & SplitString(30) & "," &
SplitString(31) & "," & SplitString(32) & "," & SplitString(33) & "," &
SplitString(34) & "," & SplitString(35) & "," & SplitString(36) & "," &
SplitString(37) & "," & SplitString(38)
myCommand = New SqlCommand(sqlstr, myConnection )
myCommand.ExecuteNonQuery()
End IF
End While
objStreamReader.Close()
File.Delete(arr)
Catch e as System.Data.SqlClient.SqlException lblMsg.Text =
"Exporting data failed"
logEvents("Login : " & session("User") & " Export data failed" )
logEvents("Login : " & session("User") & " " & e.ToString())
Flag = 0
Finally myConnection.Close()
End Try
End Sub
Thanx, Smith http://spaces.msn.com/members/johnysmith
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]