|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have been able to establish a connection to a OLEDB with vb.net windows with no problems. When I want to use an SQL statement in the data adapter that works fine too. The problem I am having is when I use something like select * from table where Shift= ' " & txtShift.text & " ' "
The following code will work in a PRIVATE SUB like behind a Button. But if I try to use any of the objects outside of the SUB I have an error. If the code is in a module or at the top of the form I can't use the SQL string since I don't have the txtShift.text yet. If I used "DAY" instead of the txtShift.text it would work but I want to be able to select various shifts and days off from the form. how do i refresh the data in the form based on the txtShift.text values ie whenevr it changes. is there any method like refresh() which i can call even if the code is placed in a module. Dim strSQL As String strSQL = "Select * from Dealers where Shift = '" & txtShift.Text & "' and off1 <> '" & txtDay.Text & "'and off2 <> '" & txtDay.Text & "' order by dealerid " Dim objconnectionNEW As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Scheduler.mdb") Dim objOwnerDANEW As New OleDb.OleDbDataAdapter(strSQL, objconnectionNEW) Dim objOwnerCBNEW As New OleDb.OleDbCommandBuilder(objOwnerDANEW) Dim objDataSetNEW As New DataSet objDataSetNEW.Clear() objOwnerDANEW.FillSchema(objDataSetNEW, SchemaType.Source, "Dealers") objOwnerDANEW.Fill(objDataSetNEW, "Dealers") DataGrid2.SetDataBinding(objDataSetNEW, "Dealers") |
|
#2
|
|||
|
|||
|
This might be the problem.
Your SELECT statement must be in Capital letters. Eg: "SELECT * FROM Contacts ORDER BY Names" Remember, SQL only recognises its commands in uppercase. The Contacts and Names are only fictitious. Just used as an example. If you have any more hassles, let me know. |
|
#3
|
|||
|
|||
|
This might help.
"SELECT * FROM Dealers WHERE Shift = '" & txtShift.Text & "' AND off1 <> '" & txtDay.Text & "'AND off2 <> '" & txtDay.Text & "' ORDER BY dealerid " |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Please help, new to vb .net |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|