Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class add_LoginMember
Inherits System.Web.UI.Page
Dim strSQL, sqlb As String
Dim md As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strConn As String
strConn = WebConfigurationManager.ConnectionStrings("Library").ConnectionString
Dim Conn As New SqlConnection(strConn)
Conn.Open()
sqlb = "SELECT COUNT(*) FROM poll_ask "
Dim cmd1 = New SqlCommand(sqlb, Conn)
md = cmd1.ExecuteScalar()
If md = 0 Then
'Label1.Visible = True
'lbl1.Visible = False
'btnsave.Visible = False
'Button2.Visible = False
Else
'Label1.Visible = False
'lbl1.Visible = True
'btnsave.Visible = True
'Button2.Visible = True
End If
Conn.Close()
End Sub
Protected Sub btnsave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsave.Click
Dim strConn As String
strConn = WebConfigurationManager.ConnectionStrings("Library").ConnectionString
Dim Conn As New SqlConnection(strConn)
Conn.Open()
Dim strConn1 As String
strConn1 = WebConfigurationManager.ConnectionStrings("Library").ConnectionString
Dim Conn1 As New SqlConnection(strConn1)
Dim cmd As New SqlCommand
Dim adapter As New SqlDataAdapter
Dim quest As New DataTable
Dim update As New DataTable
Dim ans, result, ans1, result1 As New DataTable
Dim a, b, c, num, add As Double
strSQL = "SELECT poll_ask_id,poll_ask,page_num FROM poll_ask"
cmd.Connection = Conn
cmd.CommandText = strSQL
adapter.SelectCommand = cmd
adapter.Fill(quest)
strSQL = "SELECT poll_ans_id,poll_ans,poll_ask_id FROM poll_ans "
cmd.Connection = Conn
cmd.CommandText = strSQL
adapter.SelectCommand = cmd
adapter.Fill(ans)
'TryC
For i As Integer = 0 To quest.Rows.Count - 1
a = Request.Form.GetValues("Radio" & i)(0)
strSQL = "INSERT INTO poll_ans (poll_ans,poll_ask_id) VALUES ( '" & a & "','" & quest.Rows(i).Item(0) & "')"
cmd.Connection = Conn
cmd.CommandText = strSQL
adapter.SelectCommand = cmd
adapter.Fill(update)
'Dim Myconn = New SqlConnection(Application("ConDB"))
'Myconn.Open()
Conn1.Open()
strSQL = "Select count_num from poll_ask"
Dim dsb As DataSet = New DataSet
Dim dab As SqlDataAdapter = New SqlDataAdapter(strSQL, Conn1)
dab.Fill(dsb, "poll_ask")
num = dsb.Tables(0).Rows(i).Item("count_num").ToString()
add = num + 1
strSQL = "update poll_ask set count_num ='" & add & "' where poll_ask_id = '" & quest.Rows(i).Item(0) & "'"
Dim cmd1 = New SqlCommand(strSQL, Conn1)
cmd1.ExecuteNonQuery()
Conn1.Close()
Next
MsgBox("บันทึกข้อมูลเรียบร้อยแล้ว")
'Catch ex As Exception
MsgBox("กรุณาทำให้ครบทุกข้อ")
Exit Sub
'End Try
End Sub
End Class
Error ตรงบรรทัดที่ 74 ครับ
ซึ่งพอเอาค่าออกแล้ว มันขึ้นว่า Value of type 'char' cannot be converted to 'double'