473,405 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

VB.net working with sql string does not work, help...

Hope someone can help me
The SQL string i need to use does not work, Who can help me....
Thanks in advance

Dim strConn As String
Dim strSQL As String
Dim dsArtikel As New DataSet("DataSetName")
'Dim strconn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = " & Application.StartupPath &
"\BE_MasterControl.mdb;"

Dim conn As OleDbConnection = New OleDbConnection(strConn)
Dim sqlStr As String = "SELECT * FROM tblProducten"
THIS IS WORKING
REM Dim sqlStr As String = "SELECT * FROM tblProducten where
OnzeRef = A4214" THIS DOES NOT WORK

' Create data adapter object
Dim daArtikel As OleDbDataAdapter = New OleDbDataAdapter(sqlStr,
conn)

' Create a dataset object and fill with data using data adapter's
Fill method
Dim ds As DataSet = New DataSet
daArtikel.Fill(dsArtikel, "tblProducten")

Me.DataGrid1.DataSource = dsArtikel
Me.DataGrid1.DataMember = "tblProducten"


Nov 21 '05 #1
10 1885
"April" <Ap***@village.invalid> wrote in message
news:e6*************@TK2MSFTNGP12.phx.gbl...
REM Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef =
A4214" THIS DOES NOT WORK


Presumably, the tblProdukten.OnzeRef field is not numeric? Therefore:

Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef = 'A4214'"
Nov 21 '05 #2
April,

Can you try OnzeRef = 'A4214'

I hope this helps,

Cor
Nov 21 '05 #3
Hi as Mark and Cor suggested, it most likely has to do with the ' ', but the
thing I do when I write sql string is first try them out in my database
program (sql server, access) with values I'm sure will return something.
Maybe this can help you in the future.

Greetz Peter
Nov 21 '05 #4
Ok this is working, many thanks for your help
Stupid of my not to think or try this ...

Best Regards
Marc.

"April" <Ap***@village.invalid> schreef in bericht
news:e6*************@TK2MSFTNGP12.phx.gbl...
Hope someone can help me
The SQL string i need to use does not work, Who can help me....
Thanks in advance

Dim strConn As String
Dim strSQL As String
Dim dsArtikel As New DataSet("DataSetName")
'Dim strconn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = " & Application.StartupPath &
"\BE_MasterControl.mdb;"

Dim conn As OleDbConnection = New OleDbConnection(strConn)
Dim sqlStr As String = "SELECT * FROM tblProducten" THIS IS
WORKING
REM Dim sqlStr As String = "SELECT * FROM tblProducten where
OnzeRef = A4214" THIS DOES NOT WORK

' Create data adapter object
Dim daArtikel As OleDbDataAdapter = New OleDbDataAdapter(sqlStr,
conn)

' Create a dataset object and fill with data using data adapter's
Fill method
Dim ds As DataSet = New DataSet
daArtikel.Fill(dsArtikel, "tblProducten")

Me.DataGrid1.DataSource = dsArtikel
Me.DataGrid1.DataMember = "tblProducten"

Nov 21 '05 #5
Another question,

And if I want to use a variable like "strOnzeRef"

Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef = 'A4214'"
Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef =
""'" & strOnzeRef & "'"""

I tried differents but not working

"April" <Ap***@village.invalid> schreef in bericht
news:e6*************@TK2MSFTNGP12.phx.gbl...
Hope someone can help me
The SQL string i need to use does not work, Who can help me....
Thanks in advance

Dim strConn As String
Dim strSQL As String
Dim dsArtikel As New DataSet("DataSetName")
'Dim strconn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = " & Application.StartupPath &
"\BE_MasterControl.mdb;"

Dim conn As OleDbConnection = New OleDbConnection(strConn)
Dim sqlStr As String = "SELECT * FROM tblProducten" THIS IS
WORKING
REM Dim sqlStr As String = "SELECT * FROM tblProducten where
OnzeRef = A4214" THIS DOES NOT WORK

' Create data adapter object
Dim daArtikel As OleDbDataAdapter = New OleDbDataAdapter(sqlStr,
conn)

' Create a dataset object and fill with data using data adapter's
Fill method
Dim ds As DataSet = New DataSet
daArtikel.Fill(dsArtikel, "tblProducten")

Me.DataGrid1.DataSource = dsArtikel
Me.DataGrid1.DataMember = "tblProducten"

Nov 21 '05 #6
Dim sqlStr as String = "Select * from tblProductenwhere OnzeRef = '" &
strOnzeRef & "'"
(Just to be sure you get it right the quote sequence in words OnzeRef =
single double & strOnzeRef & double single souble)

hth Greetz Peter

should do the trick
"April" <Ap***@village.invalid> schreef in bericht
news:e2**************@TK2MSFTNGP14.phx.gbl...
Another question,

And if I want to use a variable like "strOnzeRef"

Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef = 'A4214'" Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef =
""'" & strOnzeRef & "'"""

I tried differents but not working

"April" <Ap***@village.invalid> schreef in bericht
news:e6*************@TK2MSFTNGP12.phx.gbl...
Hope someone can help me
The SQL string i need to use does not work, Who can help me....
Thanks in advance

Dim strConn As String
Dim strSQL As String
Dim dsArtikel As New DataSet("DataSetName")
'Dim strconn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = " & Application.StartupPath &
"\BE_MasterControl.mdb;"

Dim conn As OleDbConnection = New OleDbConnection(strConn)
Dim sqlStr As String = "SELECT * FROM tblProducten" THIS IS
WORKING
REM Dim sqlStr As String = "SELECT * FROM tblProducten where
OnzeRef = A4214" THIS DOES NOT WORK

' Create data adapter object
Dim daArtikel As OleDbDataAdapter = New OleDbDataAdapter(sqlStr,
conn)

' Create a dataset object and fill with data using data adapter's
Fill method
Dim ds As DataSet = New DataSet
daArtikel.Fill(dsArtikel, "tblProducten")

Me.DataGrid1.DataSource = dsArtikel
Me.DataGrid1.DataMember = "tblProducten"


Nov 21 '05 #7
mind the typo souble should ofcourse be double :-)

Greetz Peter

"Peter Proost" <pp*****@nospam.hotmail.com> schreef in bericht
news:#2**************@TK2MSFTNGP10.phx.gbl...
Dim sqlStr as String = "Select * from tblProductenwhere OnzeRef = '" &
strOnzeRef & "'"
(Just to be sure you get it right the quote sequence in words OnzeRef =
single double & strOnzeRef & double single souble)

hth Greetz Peter

should do the trick
"April" <Ap***@village.invalid> schreef in bericht
news:e2**************@TK2MSFTNGP14.phx.gbl...
Another question,

And if I want to use a variable like "strOnzeRef"

Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef =

'A4214'"
Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef =
""'" & strOnzeRef & "'"""

I tried differents but not working

"April" <Ap***@village.invalid> schreef in bericht
news:e6*************@TK2MSFTNGP12.phx.gbl...
Hope someone can help me
The SQL string i need to use does not work, Who can help me....
Thanks in advance

Dim strConn As String
Dim strSQL As String
Dim dsArtikel As New DataSet("DataSetName")
'Dim strconn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = " & Application.StartupPath &
"\BE_MasterControl.mdb;"

Dim conn As OleDbConnection = New OleDbConnection(strConn)
Dim sqlStr As String = "SELECT * FROM tblProducten" THIS IS
WORKING
REM Dim sqlStr As String = "SELECT * FROM tblProducten where
OnzeRef = A4214" THIS DOES NOT WORK

' Create data adapter object
Dim daArtikel As OleDbDataAdapter = New OleDbDataAdapter(sqlStr, conn)

' Create a dataset object and fill with data using data adapter's Fill method
Dim ds As DataSet = New DataSet
daArtikel.Fill(dsArtikel, "tblProducten")

Me.DataGrid1.DataSource = dsArtikel
Me.DataGrid1.DataMember = "tblProducten"



Nov 21 '05 #8

Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef = '" &
strOnzeRef &"'"

I think this would work.
"April" wrote:
Another question,

And if I want to use a variable like "strOnzeRef"

Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef = 'A4214'"
Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef =
""'" & strOnzeRef & "'"""

I tried differents but not working

"April" <Ap***@village.invalid> schreef in bericht
news:e6*************@TK2MSFTNGP12.phx.gbl...
Hope someone can help me
The SQL string i need to use does not work, Who can help me....
Thanks in advance

Dim strConn As String
Dim strSQL As String
Dim dsArtikel As New DataSet("DataSetName")
'Dim strconn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = " & Application.StartupPath &
"\BE_MasterControl.mdb;"

Dim conn As OleDbConnection = New OleDbConnection(strConn)
Dim sqlStr As String = "SELECT * FROM tblProducten" THIS IS
WORKING
REM Dim sqlStr As String = "SELECT * FROM tblProducten where
OnzeRef = A4214" THIS DOES NOT WORK

' Create data adapter object
Dim daArtikel As OleDbDataAdapter = New OleDbDataAdapter(sqlStr,
conn)

' Create a dataset object and fill with data using data adapter's
Fill method
Dim ds As DataSet = New DataSet
daArtikel.Fill(dsArtikel, "tblProducten")

Me.DataGrid1.DataSource = dsArtikel
Me.DataGrid1.DataMember = "tblProducten"


Nov 21 '05 #9
Thank you verry mutch Peter,
Its working fine now

Greetz Marc.


"Peter Proost" <pp*****@nospam.hotmail.com> schreef in bericht
news:%2****************@TK2MSFTNGP14.phx.gbl...
mind the typo souble should ofcourse be double :-)

Greetz Peter

"Peter Proost" <pp*****@nospam.hotmail.com> schreef in bericht
news:#2**************@TK2MSFTNGP10.phx.gbl...
Dim sqlStr as String = "Select * from tblProductenwhere OnzeRef = '" &
strOnzeRef & "'"
(Just to be sure you get it right the quote sequence in words OnzeRef =
single double & strOnzeRef & double single souble)

hth Greetz Peter

should do the trick
"April" <Ap***@village.invalid> schreef in bericht
news:e2**************@TK2MSFTNGP14.phx.gbl...
> Another question,
>
> And if I want to use a variable like "strOnzeRef"
>
> Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef =

'A4214'"
> Dim sqlStr As String = "SELECT * FROM tblProducten where OnzeRef =
> ""'" & strOnzeRef & "'"""
>
> I tried differents but not working
>
>
>
> "April" <Ap***@village.invalid> schreef in bericht
> news:e6*************@TK2MSFTNGP12.phx.gbl...
> > Hope someone can help me
> > The SQL string i need to use does not work, Who can help me....
> > Thanks in advance
> >
> >
> >
> >
> >
> > Dim strConn As String
> > Dim strSQL As String
> > Dim dsArtikel As New DataSet("DataSetName")
> > 'Dim strconn As OleDbConnection
> >
> > strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
> > strConn &= "Data Source = " & Application.StartupPath &
> > "\BE_MasterControl.mdb;"
> >
> > Dim conn As OleDbConnection = New OleDbConnection(strConn)
> > Dim sqlStr As String = "SELECT * FROM tblProducten" THIS IS
> > WORKING
> > REM Dim sqlStr As String = "SELECT * FROM tblProducten
> > where
> > OnzeRef = A4214" THIS DOES NOT WORK
> >
> > ' Create data adapter object
> > Dim daArtikel As OleDbDataAdapter = New OleDbDataAdapter(sqlStr, > > conn)
> >
> > ' Create a dataset object and fill with data using data adapter's > > Fill method
> > Dim ds As DataSet = New DataSet
> > daArtikel.Fill(dsArtikel, "tblProducten")
> >
> > Me.DataGrid1.DataSource = dsArtikel
> > Me.DataGrid1.DataMember = "tblProducten"
> >
> >
> >
> >
>
>



Nov 21 '05 #10
Use stored procedures. Trust me when I say your app will be a lot more
secure.

"April" <Ap***@village.invalid> wrote in message
news:Ap***@village.invalid:
Hope someone can help me
The SQL string i need to use does not work, Who can help me....
Thanks in advance

Dim strConn As String
Dim strSQL As String
Dim dsArtikel As New DataSet("DataSetName")
'Dim strconn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = " & Application.StartupPath &
"\BE_MasterControl.mdb;"

Dim conn As OleDbConnection = New OleDbConnection(strConn)
Dim sqlStr As String = "SELECT * FROM tblProducten"
THIS IS WORKING
REM Dim sqlStr As String = "SELECT * FROM tblProducten where
OnzeRef = A4214" THIS DOES NOT WORK

' Create data adapter object
Dim daArtikel As OleDbDataAdapter = New OleDbDataAdapter(sqlStr,

conn)

' Create a dataset object and fill with data using data adapter's

Fill method
Dim ds As DataSet = New DataSet
daArtikel.Fill(dsArtikel, "tblProducten")

Me.DataGrid1.DataSource = dsArtikel
Me.DataGrid1.DataMember = "tblProducten"


Nov 21 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: viviane lima - * - * - | last post by:
Also idea ? how to use ASP for working .DBF files ? Please help me .. thanks Vivian
2
by: Athanasius | last post by:
Could someone shed some light as to why the following setTimeout function will not work on the Mac IE5.2? It does however work on PC(Forefox,Netscape,IE) & Mac(Safari,Firefox). Here is the script,...
8
by: Jim | last post by:
Need some comments from anyone willing to help, please. See the code included below. This compiles with GCC on FreeBSD 4.7. The only point of it is to accept a socket connection. Nothing else...
1
by: Roberto Castro | last post by:
I have some problems with the way I am showing the BLOB fields in the Image web controls. It does work on my localhost though sometimes I need to hit Refresh for the images to load properly....
7
by: David Freeman | last post by:
Hi There! Below is my VB.NET code... Dim strSQL As String strSQL = "SELECT , FROM Customers GROUP BY , , " Dim oleConn As OleDbConnection = Nothing
5
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find...
9
by: JT | last post by:
Here is the overall structure I will be referring to: End-program ProvideWorkFlow.dll Forms and methods that properly manipulate calls to methods in AccessUtils AccessUtils (a web service)...
3
by: =?Utf-8?B?Sm9obkJhdGVz?= | last post by:
I'm trying to (programatically) backup and clear the security event log on the local machine. I can do this manually through the event viewer and I am logged on as an administrator. I can...
6
by: vspsdca | last post by:
Hi, I'm a newbie here and does not really have any formal training on VBA. I just need help to get my hyperlink to work. I have a form in MS Access with a browse button where a user can select a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.