Hello!
I'm a beginner developer and I'm currently learning Visual Basic 2008 Express Edition. I'd like create the following program:
- search custom selected database
- if selected database contains TABLEX and if TABLEX has data in ColumnY and it equals 0 then make some sort of signal/error/report where it's wrong and what should be changed
The code so far:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
Dim sql As String ' SQL Command String
Dim cmd As OleDb.OleDbCommand ' New DB Command
Dim dbPath As String = OpenFileDialog1.FileName
Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & dbPath & "; Persist Security Info = False;"
Dim dBaseConnection As New System.Data.OleDb.OleDbConnection(connStr)
dBaseConnection.Open()
If dBaseConnection.State = 1 Then
Label1.Text = "Database loaded!"
Else
Label1.Text = "Database not loaded!"
End If
sql = "SELECT ColumnY FROM TABLEX"
cmd = New OleDb.OleDbCommand(sql, dBaseConnection)
cmd.ExecuteNonQuery()
dBaseConnection.Close()
End Sub
How I can make the selected data equal a variable/string or anything like that? I just coudn't find any solution regarding this. And what if it has more similar data and I want to check each of them if it's 0?
Thanks for all the help and answers in advance!