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

SQL Statement

Joe
How can I run a SQL statement from VB.NET

I want to set a text box equal to something retrived from a select statemen

ex

textbox.text=SELECT CAR from AUTOS where AUTO_ID= '" & editAuto_ID.Text & "'

Thanks!
Nov 20 '05 #1
4 956
Cor
Hi Joe,

Have a look at this resource kit.

There are a lot of samples in it.

Look at dataaccess.

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbr...q/#installvdir

I hope this helps a little bit?

Cor
Nov 20 '05 #2
Cor
Hi Joe,

Have a look at the "sqldatareader" that is for your question the most simple
approach I think.

http://msdn.microsoft.com/library/de...classtopic.asp

If you use oledb it is the same it is only than named oledbdatareader

Cor
Thanks for the resource kit. I am looking through it and it is rather large. Does anyone know how I can store the results of this type of
statement:
da_Models.SelectCommand.CommandText = "SELECT DESCRIPTION FROM SERVER_MODEL WHERE MODEL_ID= '" & editMODEL_ID.Text & "'"
into a command box or a variable? I just don't know how to manipulate the data once it is in this format
Thanks

Nov 20 '05 #3
Joe,

Where is the data? .Net passes SQL select statements to a SQL engine (often
MSDE or SQL Server) but it can be Access or Oracle or any of a number of
others. It is this engine that understands SQL and how to execute a query.
Typically one uses ADO.Net to address the engine so I'd start your search
there.

Tom

"Joe" <an*******@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
How can I run a SQL statement from VB.NET?

I want to set a text box equal to something retrived from a select statement
ex.

textbox.text=SELECT CAR from AUTOS where AUTO_ID= '" & editAuto_ID.Text & "'"
Thanks!

Nov 20 '05 #4
=?Utf-8?B?UENM?= <an*******@discussions.microsoft.com> wrote in
news:34**********************************@microsof t.com:

<snip>
Is there a way to refernece these fields by name? In VB 6 i could
access the field value with something similar to:

value=rs("Fieldname")

(1) value=rs("Fieldname") is actually value=rs.fields("Fieldname") Note
that you MUST specify all properties in .Net. The fields property is the
DEFAULT property in VB6 ADO. We all got lazy being able to leave this
out.

(2) The ADO recordset object, when persented with a string argument,
traverses itself looking for a match on field name and then using the
index that it located to fetch the value. If you know the index it is
much faster to just go get it. I regularly have tables with well over a
hundred fields. If I have a few thousand rows returned, which is common,
that is a few hundred thousand extra things that needed to be done for me
do get my data.

(3) Don't use SELECT *. I had several customers that applied an update
to their ERP package that rearranged the schema putting all the fields in
alphabetic order. Lots of custom code that assumed the fields to be in a
certain order broke because of SELECT *.

|==========|
| Solution |
|==========|

You can search for the field name yourself:

Dim iIndex as Integer = -1
Dim i as Integer

For i = 0 to myReader.FieldCount -1
If Ucase(sSearchArg) = Ucase(myReader.GetName(i)) Then
iIndex = i
Exit For
End If
Next i

This is what ADO was doing for you in the background anyway.

--
ATB

Charles Kincaid
Nov 20 '05 #5

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

Similar topics

28
by: Fábio Mendes | last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with things or the python-list sent my msg to /dev/null. I couldn't find anything related in previous PEP's, so here it goes a...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
28
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
18
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp...
23
by: florian.loitsch | last post by:
According to the spec Section 14 the production SourceElements:SourceElements SourceElement is evaluated as follows: 1. Evaluate SourceElements. 2. If Result(1) is an abrupt completion, return...
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:
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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.