.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 19th, 2004, 01:29 PM
attsili attsili is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 1 attsili User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Please help, new to vb .net

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")

Reply With Quote
  #2  
Old May 7th, 2004, 05:23 AM
StraussD StraussD is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 StraussD User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #3  
Old May 7th, 2004, 05:25 AM
StraussD StraussD is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 StraussD User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This might help.

"SELECT * FROM Dealers WHERE Shift = '" & txtShift.Text & "' AND off1 <> '" & txtDay.Text & "'AND off2 <> '" & txtDay.Text & "' ORDER BY dealerid "

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Please help, new to vb .net


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway