04-05-14, 06:14 PM
[quote='عابر سبيل' pid='13507' dateline='1399198800']
اخي اكتب الكود بالتعليق بداخل مربع php مثل هذا
[Imports System.Data.SqlClient
Imports System.Globalization
Public Class ser
Public Shared sqlcon As New SqlConnection
Dim sqlstatment As String
Dim sql1 As String
Dim winclass As New Class1
Private Sub ser_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
''winclass.Fillcombobox(cbojob, " jobs", "jobname", "jobid", " ")
'cbojob.SelectedIndex = -1
End Sub
Private Sub btnquery1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnquery1.Click
'--------------------------------------------------------
If sqlcon.State = ConnectionState.Open Then
sqlcon.Close()
End If
btnquery1.Enabled = False
btnnewquery1.Enabled = True
'If txtquery1.Text.Trim = " " Then
'MsgBox(" ادخل رقم الهوية ", MsgBoxStyle.Information)
'txtquery1.Focus()
'lblerror.TabIndex = "ادخل رقم الهوية لاجراء البحث "
' lblerror.ForeColor = Color.Red
'Exit Sub
'sqlcon.Close()
'End If
'If sqlcon.State = ConnectionState.Open Then
'sqlcon.Close()
'End If
sqlstatment = " "
sql1 = " "
Dim firstcont As Boolean = True
If txtquery1.Text <> " " Then
If firstcont = False Then
sqlstatment = sqlstatment & " patient . id like '%" & txtquery1.Text & "%'"
Else
firstcont = False
sqlstatment = sqlstatment & " patient . id like '%" & txtquery1.Text & "%'"
End If
End If
'sqlcon.Open()
sql1 = " Select * from patient where " & sqlstatment
Dim cmd As New SqlCommand(sql1)
cmd.Connection = sqlcon
Dim dr As SqlDataReader = cmd.ExecuteReader
If dr.HasRows Then
dr.Read()
'sqlcon.Open()
'txtrec1.Text = dr.Item(" id ")
txtname.Text = dr.Item("name")
txtid.Text = dr.Item("id")
cbojob.SelectedValue = dr.Item("jobid")
txtdate.MyText = dr.Item(" date")
txttel.Text = dr.Item("tel ")
txtphone.Text = dr.Item(" phone")
txtaddress.Text = dr.Item(" address")
txtcomment.Text = dr.Item("comments")
sqlcon.Close()
Else
lblerror.BackColor = Color.Red
lblerror.BackColor = Color.White
lblerror.Text = "السجل غير موجود "
If sqlstatment = ConnectionState.Open Then
sqlcon.Close()
End If
End If
End Sub]
[رسالة الخطأ تقول The ConnectionString property has not been initialized]
اخي اكتب الكود بالتعليق بداخل مربع php مثل هذا
[Imports System.Data.SqlClient
Imports System.Globalization
Public Class ser
Public Shared sqlcon As New SqlConnection
Dim sqlstatment As String
Dim sql1 As String
Dim winclass As New Class1
Private Sub ser_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
''winclass.Fillcombobox(cbojob, " jobs", "jobname", "jobid", " ")
'cbojob.SelectedIndex = -1
End Sub
Private Sub btnquery1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnquery1.Click
'--------------------------------------------------------
If sqlcon.State = ConnectionState.Open Then
sqlcon.Close()
End If
btnquery1.Enabled = False
btnnewquery1.Enabled = True
'If txtquery1.Text.Trim = " " Then
'MsgBox(" ادخل رقم الهوية ", MsgBoxStyle.Information)
'txtquery1.Focus()
'lblerror.TabIndex = "ادخل رقم الهوية لاجراء البحث "
' lblerror.ForeColor = Color.Red
'Exit Sub
'sqlcon.Close()
'End If
'If sqlcon.State = ConnectionState.Open Then
'sqlcon.Close()
'End If
sqlstatment = " "
sql1 = " "
Dim firstcont As Boolean = True
If txtquery1.Text <> " " Then
If firstcont = False Then
sqlstatment = sqlstatment & " patient . id like '%" & txtquery1.Text & "%'"
Else
firstcont = False
sqlstatment = sqlstatment & " patient . id like '%" & txtquery1.Text & "%'"
End If
End If
'sqlcon.Open()
sql1 = " Select * from patient where " & sqlstatment
Dim cmd As New SqlCommand(sql1)
cmd.Connection = sqlcon
Dim dr As SqlDataReader = cmd.ExecuteReader
If dr.HasRows Then
dr.Read()
'sqlcon.Open()
'txtrec1.Text = dr.Item(" id ")
txtname.Text = dr.Item("name")
txtid.Text = dr.Item("id")
cbojob.SelectedValue = dr.Item("jobid")
txtdate.MyText = dr.Item(" date")
txttel.Text = dr.Item("tel ")
txtphone.Text = dr.Item(" phone")
txtaddress.Text = dr.Item(" address")
txtcomment.Text = dr.Item("comments")
sqlcon.Close()
Else
lblerror.BackColor = Color.Red
lblerror.BackColor = Color.White
lblerror.Text = "السجل غير موجود "
If sqlstatment = ConnectionState.Open Then
sqlcon.Close()
End If
End If
End Sub]
[رسالة الخطأ تقول The ConnectionString property has not been initialized]
