Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. Private Sub Assignsched(ByVal rType As String, ByVal subjectCode As String, ByVal SecID As String, ByVal CourseCode As String)
  2. If shrdcon.con.State = ConnectionState.Closed Then
  3. shrdcon.con.Open()
  4. End If
  5. Dim RoomNum As Integer
  6. dtARoom.Clear()
  7. Dim stoploop As Boolean
  8.  
  9. Dim count As Integer = 0
  10.  
  11. Dim rm1 As String
  12. RoomAssign = ""
  13. rm1 = "SELECT * FROM tblRoom WHERE RoomType = '" & rType & "'"
  14. Dim dat As New OleDbDataAdapter(rm1, shrdcon.con)
  15. dat.Fill(ds, "ARoom")
  16.  
  17.  
  18.  
  19.  
  20. stoploop = False
  21. count = 0
  22. Do Until stoploop = "True"
  23. RoomNum = rndm.Next(0, ds.Tables("ARoom").Rows.Count)
  24. RoomAssign = ds.Tables("ARoom").Rows(RoomNum).Item(1)
  25.  
  26. ScheduleGeneration()
  27.  
  28. If checkExisting(sTime, eTime, RoomAssign, daypick) = False Then
  29.  
  30.  
  31. RoomA = RoomAssign
  32.  
  33. GenerateOfferingID()
  34. Dim cmd1 As New OleDbCommand()
  35. cmd1.CommandText = "INSERT INTO [tblSubjectOffer]([SubjectOID],[SubjectCode],[SectionID],[Day],[sTime],[eTime],[RoomName],[CourseCode]) VALUES('" & _
  36. myId & "','" & subjectCode & "','" & SecID & "','" & daypick & "'," & sTime & "," & eTime & ",'" & RoomA & "','" & CourseCode & "')"
  37. cmd1.Connection = shrdcon.con
  38. cmd1.ExecuteNonQuery()
  39. cmd1.Dispose()
  40.  
  41. Dim pipz As New OleDbCommand("Update tblGenerator Set NextNo='" & myId & "' where TableName ='" & "tblSubjectOffer" & "'", shrdcon.con)
  42. pipz.ExecuteNonQuery()
  43. pipz.Dispose()
  44. stoploop = True
  45. Else
  46. stoploop = False
  47. End If
  48. If stoploop = False Then
  49.  
  50. If count = 30 Then
  51. stoploop = True
  52. Else
  53.  
  54. count = count + 1
  55.  
  56. End If
  57. End If
  58. Loop
  59. End Sub
  60.  
  61. Private Sub Command1_Click()
  62.  
  63. Dim myConnection As ADODB.Connection
  64. Dim rsData As ADODB.Recordset
  65.  
  66. Set myConnection = New ADODB.Connection
  67. myConnection.ConnectionString = "xxxxxxxxxxxxxxxxxxxx"
  68. myConnection.Open
  69.  
  70. Set rsData = New ADODB.Recordset
  71. rsData.CursorLocation = adUseClient
  72. rsData.Open "select * from mytable", myConnection, adOpenStatic, adLockBatchOptimistic
  73.  
  74. For i = 1 To 10000
  75. rsData.AddNew
  76. rsData.Fields(0).Value = 1
  77. rsData.Fields(1).Value = 2
  78. Next i
  79.  
  80. rsData.UpdateBatch
  81.  
  82. rsData.Close
  83. myConnection.Close
  84. Set rsData = Nothing
  85. End Sub
  86.  
  87. For i = 0 To DataGridView1.RowCount - 1
  88.  
  89.  
  90. reg = DataGridView1.Rows(i).Cells(0).Value
  91. Label2.Text = reg
  92.  
  93. 'i added this two lines
  94. ***con.Close()***
  95. ***Call conState()***
  96.  
  97. Dim cmdcheck As New OleDbCommand("Select * from [2015/2016 UG CRF] where regno ='" & reg & "'", con)
  98. Dim drcheck As OleDbDataReader
  99. drcheck = cmdcheck.ExecuteReader
  100. If drcheck.Read = True Then
  101.  
  102. GoTo A
  103.  
  104. End If
  105.  
  106. coursesFirst = String.Empty
  107. coursesSecond = String.Empty
  108. creditFirst = 0
  109. creditSecond = 0
  110. Dim cmdlevel As New OleDbCommand("Select * from [2015/2016 UG registration Biodata 5 april 16] where regno ='" & reg & "'", con)
  111. Dim drlevel As OleDbDataReader
  112. drlevel = cmdlevel.ExecuteReader
  113.  
  114. If drlevel.Read = True Then
  115. level = drlevel.Item("level").ToString
  116. faculty = drlevel.Item("faculty").ToString
  117. program = drlevel.Item("programme").ToString
  118.  
  119. End If
  120.  
  121. ...............
  122.  
  123. next
  124.  
  125. Public Sub conState()
  126. If con.State = ConnectionState.Closed Then
  127. con.Open()
  128.  
  129. End If
  130.  
  131. End Sub
  132.  
  133. OleDbDataReader reader = cmd.ExecuteReader();
  134. bool result = reader.Read();
  135. reader.Close(); // <= Problem went away after adding this
  136. return result;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement