26-03-14, 07:56 PM
تفضل اخي
وفي حال لم يفتح معك لاني استخدم فيجوال بيسك 2012 هذا الكود
وفي حال لم يفتح معك لاني استخدم فيجوال بيسك 2012 هذا الكود
PHP كود :
Imports System.Data.SqlClient
Public Class Form1
Dim conn As New SqlConnection
Dim cmd As New SqlCommand
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Connection() = True Then
MsgBox("Connection Successfully", MsgBoxStyle.Information, "Connection")
Else
MsgBox("Error")
End If
End Sub
Private Function Connection()
Try
conn.ConnectionString = "Data Source=" & txtServer.Text & ";Initial Catalog=" & txtDatabase.Text & ";User ID=" & txtUser.Text & ";Password=" & txtPass.Text & ";Integrated Security=True"
cmd.Connection = conn
conn.Open()
Return True
Catch ex As Exception
MsgBox("Error : " & ex.Message, MsgBoxStyle.Critical, "Error")
Return False
End Try
End Function
End Class
