تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
كلاس لعدة تعاملات مع الداتا بيز(فتح و غلق الأتصال..سيليكت...و انسيرت ...)
#1
كاتب الموضوع : egyption-coder

الكلاس سهل و بسيط و لا يحتاج لشرح و اى سؤال انا جاهز للأجابة


كود :
Imports System.IO
Imports System.Data.OleDb

Public Class hassan
Public filestreamDist As String = "C:\surgery\dist.txt"
Public costnmlabel As String
Dim fs As New IO.FileStream(filestreamDist, FileMode.Open)

Dim sr As New IO.StreamReader(fs)
Public datasorc As String = sr.ReadLine
Public con As New OleDb.OleDbConnection

Public intmsg As Integer
Public checins As Integer
Public PASS As Integer
Public SelectedFildes(30) As String
Public empin As String
'-----------------------------------



Public Sub OpenConniction()
sr.Close()

fs.Close()



Try

con.ConnectionString = (("provider=microsoft.jet.oledb.4.0" & ";data source=" & datasorc & ";user id=admin;jet oledb:database password=26327446"))

If con.State = ConnectionState.Closed Then

con.Open()
End If





Catch Exoledb As OleDb.OleDbException
Dim message As String
Dim se As OleDb.OleDbError

For Each se In Exoledb.Errors
Select Case se.Message


Case 17
message = "Wrong Server Name"
Case 4060
message = "Wrong DataBase Name"
Case 18456
message = "Wrong User ID Or PSSWORD"
Case Else
message = se.Message
End Select
MessageBox.Show(message)
Exit Sub
Next
Catch ex As Exception

End Try

End Sub
Public Sub CloaseConniction()
If con.State = ConnectionState.Open Or con.State = ConnectionState.Connecting Then
con.Close()
End If


End Sub

Public Sub ins(ByVal str As String)
If checins = 1 Then
Exit Sub
End If
OpenConniction()

Dim has As String
Try

has = str
'--------------------------------------------------------------
Dim cuaav As OleDb.OleDbCommand
cuaav = New OleDb.OleDbCommand(has, con)
cuaav.ExecuteNonQuery()

con.Close()
'-----------------------------------------------------
Catch ex As Exception
MsgBox(ex.Message)
con.Close()
End Try
checins = 0
MsgBox("تم الأدخال بنجاح")
End Sub
Public Sub inschek(ByVal strc As String, ByVal strmsg As String)
Dim rdr As Integer
OpenConniction()
Try
Dim insss As String

insss = strc
Dim cu As OleDb.OleDbCommand
cu = New OleDb.OleDbCommand(insss, con)
Dim dr As OleDb.OleDbDataReader

dr = cu.ExecuteReader()
While (dr.Read())
rdr = dr.GetValue(0)


Exit While
End While

dr.Close()




'-----------------------------------------------------
Catch ex As Exception
MsgBox(ex.Message)
con.Close()
End Try

'----------------------------------------------------------


If rdr > 0 Then
con.Close()


intmsg = MsgBox(strmsg, MessageBoxButtons.YesNo, MessageBoxIcon.Question)


checins = 1
Else

checins = 0
End If

End Sub
Public Sub SelectCommand(ByVal CommandString As String, ByVal ParameterName() As String, ByVal ParametersValues() As String)
OpenConniction()
Dim cmd As New OleDbCommand(CommandString, con)
Dim ii As Integer
For ii = 0 To ParameterName.Length - 1
cmd.Parameters.AddWithValue(ParameterName(ii), ParametersValues(ii))
Next


Try

Dim dr As OleDb.OleDbDataReader
Dim nn As Integer

dr = cmd.ExecuteReader()
While (dr.Read())
For nn = 0 To dr.FieldCount - 1
SelectedFildes(nn) = dr.GetValue(nn)
Next

End While





dr.Close()




'-----------------------------------------------------
Catch ex As Exception
MsgBox("please insert a sutable valu")
con.Close()
End Try
End Sub

Public Sub ClearTextBox(ByVal root As Control)
For Each ctrl As Control In root.Controls
ClearTextBox(ctrl)
If TypeOf ctrl Is TextBox Then
CType(ctrl, TextBox).Text = String.Empty

End If
Next ctrl

End Sub
Public Sub CloseForm(ByVal root As Control, ByVal fname As String)

For Each ctrl As Control In root.Controls
CloseForm(ctrl, fname)

If TypeOf ctrl Is Form AndAlso ctrl.Name <> fname Then
ctrl.Hide()

End If
Next ctrl

End Sub

' ClearTextBox(Me)

End Class
}}}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  كلاس Data Access Layer RaggiTech 0 454 17-10-12, 09:01 PM
آخر رد: RaggiTech
  كلاس تصوير الويبكام RaggiTech 0 400 17-10-12, 08:58 PM
آخر رد: RaggiTech

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم