Imports System.Data.SqlClient
Imports System.Data
Partial Class addvote2
    Inherits System.Web.UI.Page
    Dim con As String = " Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyData.mdf;Integrated Security=True;User Instance=True"
    Dim sqlcon As New SqlConnection(con)
    Dim sql As String
    Dim da As SqlDataAdapter
    Dim ds As New DataSet
    Dim cmd As New SqlCommand
    Dim dread As SqlDataReader

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Then
            MsgBox("يجب تعبئة جميع الحقول")
            Exit Sub
        End If
        sql = "insert into voting(q_name,a1,a2,a3,a4,status)" & "values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & "0" & "')"
        cmd = New SqlCommand(sql, sqlcon)
        sqlcon.Open()
        cmd.ExecuteNonQuery()
        sqlcon.Close()
        MsgBox("لقد تمت عملية إضافة السؤال والخيارات التابعه له بنجاح", , "نتيجة عملية الحفظ")

        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
    End Sub
End Class
