I am Using VB 2008. I created a project in VB 2008 with a MS Access 2003 db. The DB is accessed from outside the VB Project. The DataSet, Record Source are all set up in the Project and I can write data, delete data from the DB when I run the VB project.
Here is where I am confused.
I am attempting to incorporate a SQL query in my VB code. Shouldn't I be able to incorporate my SQL code without setting up ADO, Recordsets and that sort of stuff due to the fact that I have my DataSet, Record source already set up in the VB 2008 Project?
Here is what I am tring to do:
There are 2 Forms in my Project, Form1 and Form2, their DataSources are Table A and Table B respectively from my DB. I have a Combo Box on my Form2 which have as its recordsource data from Table A. I have three Text Boxes on my Form2 which I want to be filled in with data from Table A when I select a item from the combo box. My Code is as follows:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim cbContents As String = Me.ComboBox1.Text
Dim strSQL As String
Dim strSQL2 As String
Dim strSQL3 As String
strSQL = "SELECT FirstName FROM Managers "
strSQL = strSQL & "WHERE FirstName = " & "'" & cbContents & "';"
strSQL2 = "SELECT LastName FROM Managers "
strSQL2 = strSQL2 & "WHERE FirstName = " & "'" & cbContents & "';"
strSQL3 = "SELECT FileName FROM Managers "
strSQL3 = strSQL3 & "WHERE FirstName = " & "'" & cbContents & "';"
Me.TextBox1.Text = strSQL
Me.TextBox2.Text = strSQL2
Me.TextBox3.Text = strSQL3
End Sub
I am fairly new to VB, Help!!!
Here is where I am confused.
I am attempting to incorporate a SQL query in my VB code. Shouldn't I be able to incorporate my SQL code without setting up ADO, Recordsets and that sort of stuff due to the fact that I have my DataSet, Record source already set up in the VB 2008 Project?
Here is what I am tring to do:
There are 2 Forms in my Project, Form1 and Form2, their DataSources are Table A and Table B respectively from my DB. I have a Combo Box on my Form2 which have as its recordsource data from Table A. I have three Text Boxes on my Form2 which I want to be filled in with data from Table A when I select a item from the combo box. My Code is as follows:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim cbContents As String = Me.ComboBox1.Text
Dim strSQL As String
Dim strSQL2 As String
Dim strSQL3 As String
strSQL = "SELECT FirstName FROM Managers "
strSQL = strSQL & "WHERE FirstName = " & "'" & cbContents & "';"
strSQL2 = "SELECT LastName FROM Managers "
strSQL2 = strSQL2 & "WHERE FirstName = " & "'" & cbContents & "';"
strSQL3 = "SELECT FileName FROM Managers "
strSQL3 = strSQL3 & "WHERE FirstName = " & "'" & cbContents & "';"
Me.TextBox1.Text = strSQL
Me.TextBox2.Text = strSQL2
Me.TextBox3.Text = strSQL3
End Sub
I am fairly new to VB, Help!!!