473,386 Members | 1,958 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,386 software developers and data experts.

Database SQL Statement

I just downloaded this VB Express. I need a little help in understanding the request
for database data, that is the format/syntax compared to an SQL statement.

In my SQL I would use a select statement... example

select LastName from Members where month(Birthday) = month(now)

How would this be coded in VB Express?

Earl

Jun 27 '08 #1
12 1084
You can do it the exact same way or you can look into Stored
Procedures/SQL Functions. You could even go the route of LINQ.

As far as doing it the same way you're doing it you'll need the
SQLConnection, SQLCommand, and SQLDataReader objects.
or
You could go the route of datasets.

All in all there are tons of different ways to retrieve data from a
database just pick which one suits your style and application and
enjoy.

Jun 27 '08 #2
I would like to stick with what I'm familiar with, but every time I try to
do a
"select xName from member where FName = "Dan" I get the response that
thinks I'm trying to do a Select Case.
Earl

"cfps.Christian" <ge*******@otc.eduwrote in message
news:8b**********************************@t63g2000 hsf.googlegroups.com...
You can do it the exact same way or you can look into Stored
Procedures/SQL Functions. You could even go the route of LINQ.

As far as doing it the same way you're doing it you'll need the
SQLConnection, SQLCommand, and SQLDataReader objects.
or
You could go the route of datasets.

All in all there are tons of different ways to retrieve data from a
database just pick which one suits your style and application and
enjoy.

Jun 27 '08 #3
"Earl Partridge" <ea*****@pearnet.comschrieb
I just downloaded this VB Express. I need a little help in
understanding the request
for database data, that is the format/syntax compared to an SQL
statement.

In my SQL I would use a select statement... example

select LastName from Members where month(Birthday) = month(now)

How would this be coded in VB Express?
At which point are you stuck? The SQL statement will be the same.

General docs:
http://msdn2.microsoft.com/en-us/library/wzabh8c4.aspx
Armin

Jun 27 '08 #4
On Tue, 22 Apr 2008 17:07:17 -0400, "Earl Partridge"
<ea*****@pearnet.comwrote:
>I would like to stick with what I'm familiar with, but every time I try to
do a
"select xName from member where FName = "Dan" I get the response that
thinks I'm trying to do a Select Case.
SQL is not VB.

You will need to add either System.Data.SQLClient or System.Data.ODBC
to your project. Then you will need to define and instantiate and Open
a Connection object. You then need to define and instantiate a Command
object linked to the open Connection. Then load the SQL command into
the Command object's CommandText property. You then need to set a
DataReader object to the return value of the Command's ExecuteReader
method. Then you would use the DataReader's Read method to return the
rows one at a time, and access the resultset values with the
DataReader.
>
"cfps.Christian" <ge*******@otc.eduwrote in message
news:8b**********************************@t63g200 0hsf.googlegroups.com...
>You can do it the exact same way or you can look into Stored
Procedures/SQL Functions. You could even go the route of LINQ.

As far as doing it the same way you're doing it you'll need the
SQLConnection, SQLCommand, and SQLDataReader objects.
or
You could go the route of datasets.

All in all there are tons of different ways to retrieve data from a
database just pick which one suits your style and application and
enjoy.
Jun 27 '08 #5
After a bit of practice and experimenting, I do have the database open and
no errors in what I think is a LINQ statment... like
Dim q = From Member In BirthdaysDataSet.Member Select Member.MName

Now I'm trying to venture further to select specific records using Left$,
such as
"where left$(MName,3) = "Mik"

And also having trouble with getting a count of records.

Thanks.
Earl

"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
"Earl Partridge" <ea*****@pearnet.comschrieb
>I just downloaded this VB Express. I need a little help in understanding
the request
for database data, that is the format/syntax compared to an SQL
statement.

In my SQL I would use a select statement... example

select LastName from Members where month(Birthday) = month(now)

How would this be coded in VB Express?

At which point are you stuck? The SQL statement will be the same.

General docs:
http://msdn2.microsoft.com/en-us/library/wzabh8c4.aspx
Armin

Jun 27 '08 #6
Earl,

You cannot do that as your Select statement is a kind of impossible statement.

It should at least be something as if it was in Transact SQL as

\\\
Select LastName from Members where BirthDay PreviousMonth And BirthDay < NextMonth
///

Or in VB something as

\\\
dim ar as new arraylist
for each person in persons
if person.birthday.month = now.month then
arrayList.Add(person)
end if
end for
//

Like natural languages you cannot create your own language.

As sample:

Zoals uzywane linque lei non peu make votre sprache.

All correct words in any language but beside Herfried for nobody probably readable in this group.

Cor
"Earl Partridge" <ea*****@pearnet.comschreef in bericht news:e4**************@TK2MSFTNGP06.phx.gbl...
I just downloaded this VB Express. I need a little help in understanding the request
for database data, that is the format/syntax compared to an SQL statement.

In my SQL I would use a select statement... example

select LastName from Members where month(Birthday) = month(now)

How would this be coded in VB Express?

Earl

Jun 27 '08 #7
"Earl Partridge" <ea*****@pearnet.comschrieb
After a bit of practice and experimenting, I do have the database
open and no errors in what I think is a LINQ statment... like
Dim q = From Member In BirthdaysDataSet.Member Select Member.MName

Now I'm trying to venture further to select specific records using
Left$, such as
"where left$(MName,3) = "Mik"

And also having trouble with getting a count of records.

Unfortunatelly, I don't know anything about LINQ yet, but I think SQLs
are put in an OleDBcommand/SQLCommand's CommandText property, then call
ExecuteReader.
Armin

Jun 27 '08 #8
Where I'm having trouble appears to be in the syntax. In your example...
if person.birthday.month = now.month then

Is person the table name or field name?

Not wanting or expecting anyone to write my code, but perhaps if I provide a sample
of my database, you might be better able to point me correctly.

DB Name Birthdays (In project as "BirthdaysDataSet")
Table Name: Member
Field Names: MName, Birthdate

Then using your example would I...
for each Member in Birthdays
if Member.Birthdate.month = now.month then
code
end if
end for

Earl
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message news:DE**********************************@microsof t.com...
Earl,

Or in VB something as

\\\
dim ar as new arraylist
for each person in persons
if person.birthday.month = now.month then
arrayList.Add(person)
end if
end for
//

Cor
"Earl Partridge" <ea*****@pearnet.comschreef in bericht news:e4**************@TK2MSFTNGP06.phx.gbl...
I just downloaded this VB Express. I need a little help in understanding the request
for database data, that is the format/syntax compared to an SQL statement.

In my SQL I would use a select statement... example

select LastName from Members where month(Birthday) = month(now)

How would this be coded in VB Express?

Earl

Jun 27 '08 #9
Left$ doesn't exists (this is VB6). Try just Left or even better
MName.Substring(0,3)="Mik" (I'm not sure LINQ in VB.NET is able to handle VB
Specfic statements) or a like statement that should be avauilable....

The error you get could also help.

"Earl Partridge" <ea*****@pearnet.coma écrit dans le message de groupe de
discussion : uC**************@TK2MSFTNGP02.phx.gbl...
After a bit of practice and experimenting, I do have the database open and
no errors in what I think is a LINQ statment... like
Dim q = From Member In BirthdaysDataSet.Member Select Member.MName

Now I'm trying to venture further to select specific records using Left$,
such as
"where left$(MName,3) = "Mik"

And also having trouble with getting a count of records.

Thanks.
Earl

"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>"Earl Partridge" <ea*****@pearnet.comschrieb
>>I just downloaded this VB Express. I need a little help in
understanding the request
for database data, that is the format/syntax compared to an SQL
statement.

In my SQL I would use a select statement... example

select LastName from Members where month(Birthday) = month(now)

How would this be coded in VB Express?

At which point are you stuck? The SQL statement will be the same.

General docs:
http://msdn2.microsoft.com/en-us/library/wzabh8c4.aspx
Armin

Jun 27 '08 #10
Earl,

In that case assuming that BirthdaysDataset is not the class but the
instanced dataset is is something like this strongly typed.

for each row as BirthdaysDataSet.MemberRow in BirthdaysDataSet.Member
if row.Birthdate.month = now.month then
code
end if
end for

Non strongly typed
for each row in BirthDaysDataSet.Tables("Member").Rows
if DirectCast(row("Birthdate"),DateTime).Month = now.month then
code
end if
end for
"Earl Partridge" <ea*****@pearnet.comschreef in bericht
news:e$**************@TK2MSFTNGP06.phx.gbl...
Where I'm having trouble appears to be in the syntax. In your example...
if person.birthday.month = now.month then

Is person the table name or field name?

Not wanting or expecting anyone to write my code, but perhaps if I provide a
sample
of my database, you might be better able to point me correctly.

DB Name Birthdays (In project as "BirthdaysDataSet")
Table Name: Member
Field Names: MName, Birthdate

Then using your example would I...
for each Member in Birthdays
if Member.Birthdate.month = now.month then
code
end if
end for

Earl
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:DE**********************************@microsof t.com...
Earl,

Or in VB something as

\\\
dim ar as new arraylist
for each person in persons
if person.birthday.month = now.month then
arrayList.Add(person)
end if
end for
//

Cor
"Earl Partridge" <ea*****@pearnet.comschreef in bericht
news:e4**************@TK2MSFTNGP06.phx.gbl...
I just downloaded this VB Express. I need a little help in understanding
the request
for database data, that is the format/syntax compared to an SQL statement.

In my SQL I would use a select statement... example

select LastName from Members where month(Birthday) = month(now)

How would this be coded in VB Express?

Earl

Jun 27 '08 #11
Ahhh, it is that "row" thing. I got it to work with your first example.
Is "row" a reserved word? I don't anticipate doing much data manipulation
in
the VB.Net, simply retrieving and displaying data. I will continue to
manage the
database from MS Access. Could you point me to some helpful books on this
might help be understand better what I'm doing?
Earl
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:C0**********************************@microsof t.com...
Earl,

In that case assuming that BirthdaysDataset is not the class but the
instanced dataset is is something like this strongly typed.

for each row as BirthdaysDataSet.MemberRow in BirthdaysDataSet.Member
if row.Birthdate.month = now.month then
code
end if
end for

Non strongly typed
for each row in BirthDaysDataSet.Tables("Member").Rows
if DirectCast(row("Birthdate"),DateTime).Month = now.month then
code
end if
end for
"Earl Partridge" <ea*****@pearnet.comschreef in bericht
news:e$**************@TK2MSFTNGP06.phx.gbl...
Where I'm having trouble appears to be in the syntax. In your example...
if person.birthday.month = now.month then

Is person the table name or field name?

Not wanting or expecting anyone to write my code, but perhaps if I provide
a sample
of my database, you might be better able to point me correctly.

DB Name Birthdays (In project as "BirthdaysDataSet")
Table Name: Member
Field Names: MName, Birthdate

Then using your example would I...
for each Member in Birthdays
if Member.Birthdate.month = now.month then
code
end if
end for

Earl
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:DE**********************************@microsof t.com...
Earl,

Or in VB something as

\\\
dim ar as new arraylist
for each person in persons
if person.birthday.month = now.month then
arrayList.Add(person)
end if
end for
//

Cor
"Earl Partridge" <ea*****@pearnet.comschreef in bericht
news:e4**************@TK2MSFTNGP06.phx.gbl...
I just downloaded this VB Express. I need a little help in understanding
the request
for database data, that is the format/syntax compared to an SQL statement.

In my SQL I would use a select statement... example

select LastName from Members where month(Birthday) = month(now)

How would this be coded in VB Express?

Earl

Jun 27 '08 #12
Earl,

This is a practical one.

Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)

There are not much books about VB and Jet (the official name for what you
call Access) anymore.

However SQL Express is as well free.

Cor

"Earl Partridge" <ea*****@pearnet.comschreef in bericht
news:OB**************@TK2MSFTNGP05.phx.gbl...
Ahhh, it is that "row" thing. I got it to work with your first example.
Is "row" a reserved word? I don't anticipate doing much data manipulation
in
the VB.Net, simply retrieving and displaying data. I will continue to
manage the
database from MS Access. Could you point me to some helpful books on this
might help be understand better what I'm doing?
Earl
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:C0**********************************@microsof t.com...
>Earl,

In that case assuming that BirthdaysDataset is not the class but the
instanced dataset is is something like this strongly typed.

for each row as BirthdaysDataSet.MemberRow in BirthdaysDataSet.Member
if row.Birthdate.month = now.month then
code
end if
end for

Non strongly typed
for each row in BirthDaysDataSet.Tables("Member").Rows
if DirectCast(row("Birthdate"),DateTime).Month = now.month then
code
end if
end for
"Earl Partridge" <ea*****@pearnet.comschreef in bericht
news:e$**************@TK2MSFTNGP06.phx.gbl...
Where I'm having trouble appears to be in the syntax. In your example...
if person.birthday.month = now.month then

Is person the table name or field name?

Not wanting or expecting anyone to write my code, but perhaps if I
provide a sample
of my database, you might be better able to point me correctly.

DB Name Birthdays (In project as "BirthdaysDataSet")
Table Name: Member
Field Names: MName, Birthdate

Then using your example would I...
for each Member in Birthdays
if Member.Birthdate.month = now.month then
code
end if
end for

Earl
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:DE**********************************@microso ft.com...
Earl,

Or in VB something as

\\\
dim ar as new arraylist
for each person in persons
if person.birthday.month = now.month then
arrayList.Add(person)
end if
end for
//

Cor
"Earl Partridge" <ea*****@pearnet.comschreef in bericht
news:e4**************@TK2MSFTNGP06.phx.gbl...
I just downloaded this VB Express. I need a little help in understanding
the request
for database data, that is the format/syntax compared to an SQL
statement.

In my SQL I would use a select statement... example

select LastName from Members where month(Birthday) = month(now)

How would this be coded in VB Express?

Earl

Jun 27 '08 #13

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

Similar topics

6
by: Clay Beatty | last post by:
When you create database diagrams in Enterprise Manager, the details for constructing those diagrams is saved into the dtproperties table. This table includes an image field which contains most of...
2
by: Little PussyCat | last post by:
Hello, I hope you can help me. We have a SQL Server 2000 database at work, (which works with a VB6 frontend) which grew to a considerable size, so one of my past colleagues sent me this...
0
by: Pentti | last post by:
Can anyone help to understand why re-parsing occurs on a remote database (using database links), even though we are using a prepared statement on the local database: Scenario: ======== We...
5
by: Terry | last post by:
Hi All, Im having problems setting up the federated database. The commands Im using are as follows: CATALOG TCPIP NODE 'FSYS1' REMOTE <ip> SERVER <port> CREATE SERVER svr_docket TYPE...
2
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
1
by: jatinder.saundh | last post by:
Hi, How do I give create database privielege to a specific user/group at a particular db2 instance ? I read about various authorities like SYSCTRL etc. but I am interested in giving only Create...
10
by: shsandeep | last post by:
The ETL application loaded around 3000 rows in 14 seconds in a Development database while it took 2 hours to load in a UAT database. UAT db is partitioned. Dev db is not partitioned. the...
9
by: Jerim79 | last post by:
I am no PHP programmer. At my current job I made it known that I was no PHP programmer during the interview. Still they have given me a script to write with the understanding that it will take me a...
22
Frinavale
by: Frinavale | last post by:
How To Use A Database In Your Program Many .NET solutions are database driven and so many of us often wonder how to access the database. To help you understand the answer to this question I've...
1
Curtis Rutland
by: Curtis Rutland | last post by:
How To Use A Database In Your Program Part II This article is intended to extend Frinny’s excellent article: How to Use a Database in Your Program. Frinny’s article defines the basic concepts...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.