14-04-14, 09:05 PM
(آخر تعديل لهذه المشاركة : 15-04-14, 05:05 AM {2} بواسطة الشاكي لله.)
السلام عليكم رجاء برمجة الكوود فى ويب سيرفس
الكود يقوم بانشاء قاعدة بيانات باسم مستخدم وكلمة سر
ويمكن تسجيل عضو جديد
وتسجيل الدخول
الكود يقوم بانشاء قاعدة بيانات باسم مستخدم وكلمة سر
ويمكن تسجيل عضو جديد
وتسجيل الدخول
PHP كود :
Public str As String = "server=.\sqlexpress;initial catalog=pics;integrated security=true;"
Public con As New SqlConnection(str)
Public Function isdbfound(ByVal constr As String, ByVal dbname As String) As Boolean
Dim mc As New SqlConnection(constr)
Dim a As New SqlCommand("select count(name) from master.dbo.sysdatabases where name='" & dbname & "'", mc)
If mc.State = ConnectionState.Closed Then
mc.Open()
End If
If a.ExecuteScalar <= 0 Then
Return False
Else
Return True
End If
End Function
Public Function istbfound(ByVal tb As String) As Boolean
Dim m As New SqlCommand("select count(name) from sys.tables where name='" & tb & "'", con)
If con.State = ConnectionState.Closed Then
con.Open()
End If
If m.ExecuteScalar <= 0 Then
Return False
Else
Return True
End If
End Function
Function istusersfound(ByVal tb As String) As Boolean
Dim m As New SqlCommand("select count(name) from sys.tables where name='" & tb & "'", con)
If con.State = ConnectionState.Closed Then
con.Open()
End If
If m.ExecuteScalar <= 0 Then
Return False
Else
Return True
End If
End Function
Sub ctusers()
If istusersfound("tusers") = False Then
Dim i As New SqlCommand("create table tusers(tid int NOT NULL PRIMARY KEY identity,un varchar(200),ps varchar(200))", con)
If con.State = ConnectionState.Closed Then
con.Open()
End If
Try
i.ExecuteNonQuery()
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.Critical, "")
End Try
End If
End Sub
Sub cdb()
Dim mcc As New SqlConnection("server=.\sqlexpress;integrated security=true;")
If isdbfound("server=.\sqlexpress;integrated security=true;", "pics") = False Then
Dim cc As New SqlCommand("CREATE DATABASE pics", mcc)
If mcc.State = ConnectionState.Closed Then
mcc.Open()
End If
cc.ExecuteNonQuery()
End If
End Sub
Sub ctb()
If istbfound("pic") = False Then
Dim i As New SqlCommand("create table pic(tid int NOT NULL PRIMARY KEY identity,mgid varchar(200),mg varbinary(max))", con)
If con.State = ConnectionState.Closed Then
con.Open()
End If
Try
i.ExecuteNonQuery()
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.Critical, "")
End Try
End If
End Sub
Function addme(ByVal un As TextBox, ByVal ps As TextBox) As Boolean
Dim cm As New SqlCommand("insert into tusers(un,ps) values(@un,@ps)", con)
cm.Parameters.AddWithValue("@un", un.Text)
cm.Parameters.AddWithValue("@ps", ps.Text)
If con.State = ConnectionState.Closed Then
con.Open()
End If
Try
cm.ExecuteNonQuery()
Return True
Catch ex As Exception
Return False
End Try
End Function
Function isok(ByVal un As TextBox, ByVal ps As TextBox) As Boolean
Dim cm As New SqlCommand("select count(un) from tusers where un=@un and ps=@ps", con)
cm.Parameters.AddWithValue("@un", un.Text)
cm.Parameters.AddWithValue("@ps", ps.Text)
If con.State = ConnectionState.Closed Then
con.Open()
End If
Try
If cm.ExecuteScalar <= 0 Then
Return False
Else
Return True
End If
Catch ex As Exception
Return False
End Try
End Function