Hi folks,
I need help using the data I retrieve from Access in SQL syntax. This is my code btw:
f Code:
Imports System.Data.OleDb Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim con As New OleDb.OleDbConnection Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql As String Dim nilai As String con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Users\hadi\Desktop\SISTEM PENGUNDIAN ELEKTRONIK\SISTEM PENGUNDIAN ELEKTRONIK\Mini Projek_database.mdb" con.Open() sql = "SELECT StudentID FROM Calon" da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds, "Calon") nilai = ds.Tables("Calon").Rows(0).Item("StudentID") RadioButton1.Text = nilai ' Dim con As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=C:\Users\hadi\Desktop\SISTEM PENGUNDIAN ELEKTRONIK\SISTEM PENGUNDIAN ELEKTRONIK\Mini Projek_database.mdb") Dim cmd As OleDbCommand If RadioButton1.Checked = True Then cmd = New OleDbCommand("UPDATE Calon SET Jumlah_Undi=Jumlah_Undi+1 WHERE StudentID = 'RadioButton1.text'", con) Dim sdr As OleDbDataReader = cmd.ExecuteReader() ElseIf RadioButton2.Checked = True Then cmd = New OleDbCommand("UPDATE Calon SET Jumlah_Undi=Jumlah_Undi+1 WHERE StudentID = '01DIP09F107'", con) Dim sdr As OleDbDataReader = cmd.ExecuteReader() End If
Using RadioButton1.text in the SQL syntax don't work even the RadioButton1.text hold the value of StudentID. but using StudentID value like eg: 01DIP09F107 is working good! Note that 01DIP09F107 is in my StudentID column.
Now where did I do wrong?Thanks for any help. I'm looking at this thread http://www.vbforums.com/showthread.php?t=356711 right bow and comparing my code...


Thanks for any help. I'm looking at this thread
Reply With Quote



