Advertisement
Advertisement
| 05.13.2008 at 11:45PM PDT, ID: 23400443 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: |
The code for loading the datagridview is:
Public Sub ExecuteSP(ByVal DataTableName As String, ByVal strSQL As String)
'Running stored procedures has been timed as being faster than running SQL commands
'If DataTableName is nothing, then execute a SQL command, no table returned
'The DataTables are defined globally in modSQL.vb
'If a thread and a normal call to this function occur at the same time then a connection error will occur
'doevents until available
Do Until SQLprocessing = False
System.Windows.Forms.Application.DoEvents()
Loop
SQLprocessing = True
dt = New DataTable
Dim command As SqlCommand = New SqlCommand("usp_ExecString", oConnSQL)
command.Parameters.Add("@sqlStr", strSQL)
command.CommandType = CommandType.StoredProcedure
'Dim adapter As SqlDataAdapter = New SqlDataAdapter(command)
adapter = New SqlDataAdapter(command)
Try
Select Case DataTableName
Case "dtClient"
indexC = 0
dtClient = New DataTable
adapter.Fill(dtClient)
Case "dtClientSchedule"
dtClientSchedule = New DataTable
adapter.Fill(dtClientSchedule)
Case "dtClientPayment"
dtClientPayment = New DataTable
adapter.Fill(dtClientPayment)
Case "dtTemp"
dtTemp = New DataTable
adapter.Fill(dtTemp)
Case "dtAddress"
dtAddress = New DataTable
adapter.Fill(dtAddress)
Case "dtLandLord"
dtLandLord = New DataTable
adapter.Fill(dtLandLord)
Case "dtSecurities"
dtSecurities = New DataTable
adapter.Fill(dtSecurities)
Case "dtContacts"
dtContacts = New DataTable
adapter.Fill(dtContacts)
Case "dtEmployer"
dtEmployer = New DataTable
adapter.Fill(dtEmployer)
Case "dtSQL"
dtSQL = New DataTable
adapter.Fill(dtSQL)
Case "dtLocalPayments"
dtLocalPayments = New DataTable
adapter.Fill(dtLocalPayments)
Case "dtNotices"
dtNotices = New DataTable
adapter.Fill(dtNotices)
Case "dtMessages"
dtMessages = New DataTable
adapter.Fill(dtMessages)
Case "dtHistory"
dtHistory = New DataTable
adapter.Fill(dtHistory)
Case Else
Dim command1 As New SqlCommand(strSQL, oConnSQL)
Debug.Print(strSQL)
Try
Dim cmd As New SqlCommand
'Dim p1 As New SqlParameter("@UserName", SqlDbType.NVarChar)
'Dim p2 As New SqlParameter("@UserPwd", SqlDbType.NVarChar)
'p1.Value = strUser
'p2.Value = strPwd
'cmd.Parameters.Add(p1)
'cmd.Parameters.Add(p2)
cmd.Connection = oConnSQL 'cnn
If oConnSQL.State = ConnectionState.Closed Then
oConnSQL.Open()
End If
cmd.CommandText = strSQL
cmd.ExecuteNonQuery()
Catch ex As SqlException
MsgBox(ex.Message)
Catch ex As Exception
MsgBox(ex.Message)
End Try
'Debug.Print(strSQL)
End Select
Catch ex As Exception
Debug.Print(ex.ToString)
Debug.Print(strSQL)
End Try
SQLprocessing = False
|