Hi,
I have just learned from the link http://support.microsoft.com/kb/821765/EN-US/ to use the
database with VB .NET
From the example of the above link, if I want to use the
table Student as reference table, I need to verify if the
SNo existing in the database, then the SName is matching
with that SNo is existed in the database. The Error to
handle the case will be:
IDERROR=1 IF SNo does not have that ID
IDERROR=2 IF SName does not match with the existing ID.
The Wizard from the "OleDbDataAdapt er" automatically
generate the four SQL update, delete, insert... for me. I
want to add a SQL statements as the following:
SELECT *
FROM student
WHERE student.SNo="In put from the textbox of VB .NET".
If the return is null, the IDERROR=1
SELECT *
FROM student
WHERE student.SNo="In put from the textbox of VB .NET"
AND student.SName=" Input from the textbox of VB .NET"
If the return is null, the IDERROR=2
Could someone help me to accomplish it, please.
Thanks,
/CC. 3 3236
Charlie,
I think that you can use for your question the SQLcommand.exec utescalar http://msdn.microsoft.com/library/de...calartopic.asp
Go up in the links in the page how to use this.
I hope this helps?
Cor
"CharlieCha u" <co**********@h otmail.com> Hi,
I have just learned from the link http://support.microsoft.com/kb/821765/EN-US/ to use the database with VB .NET
From the example of the above link, if I want to use the table Student as reference table, I need to verify if the SNo existing in the database, then the SName is matching with that SNo is existed in the database. The Error to handle the case will be:
IDERROR=1 IF SNo does not have that ID IDERROR=2 IF SName does not match with the existing ID.
The Wizard from the "OleDbDataAdapt er" automatically generate the four SQL update, delete, insert... for me. I want to add a SQL statements as the following:
SELECT * FROM student WHERE student.SNo="In put from the textbox of VB .NET". If the return is null, the IDERROR=1
SELECT * FROM student WHERE student.SNo="In put from the textbox of VB .NET" AND student.SName=" Input from the textbox of VB .NET" If the return is null, the IDERROR=2
Could someone help me to accomplish it, please.
Thanks, /CC.
thanks you very much Cor Lightert. I did try your
suggestion with the following code:
Dim SqlConnection1 As SqlConnection
SqlConnection1 = New SqlConnection(" server =
localhost;uid=; password=;datab ase=testdb")
Dim SQLStatement As String = "SELECT * FROM
student"
Dim RecordCount As Integer
Dim SelectCommand As New SqlClient.SqlCo mmand
(SQLStatement, SqlConnection1)
Try
SqlConnection1. Open()
RecordCount = CInt(SelectComm and.ExecuteScal ar
())
Catch ex As Exception
MessageBox.Show ("Failed to execute command")
Finally
SqlConnection1. Close()
End Try
MessageBox.Show ("Customers table contains " &
RecordCount & " records")
But I can not well establish the connection. It seems to
me that the parameters SqlConnection1 does not work well,
but I do not know which parameters. Since I always get
the catch error message: ("Failed to execute command").
Could you give me some more hints.
Thanks,
/CC. -----Original Message----- Charlie,
I think that you can use for your question the
SQLcommand.exec utescalar http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpref/html/frlrfsystemdata sqlclientsqlcom mandclassexecu
tescalartopic.a sp Go up in the links in the page how to use this.
I hope this helps?
Cor
"CharlieChau " <co**********@h otmail.com>
Hi,
I have just learned from the link http://support.microsoft.com/kb/821765/EN-US/ to use
the database with VB .NET
From the example of the above link, if I want to use
the table Student as reference table, I need to verify if
the SNo existing in the database, then the SName is
matching with that SNo is existed in the database. The Error to handle the case will be:
IDERROR=1 IF SNo does not have that ID IDERROR=2 IF SName does not match with the existing ID.
The Wizard from the "OleDbDataAdapt er" automatically generate the four SQL update, delete, insert... for
me. I want to add a SQL statements as the following:
SELECT * FROM student WHERE student.SNo="In put from the textbox of VB .NET". If the return is null, the IDERROR=1
SELECT * FROM student WHERE student.SNo="In put from the textbox of VB .NET" AND student.SName=" Input from the textbox of VB .NET" If the return is null, the IDERROR=2
Could someone help me to accomplish it, please.
Thanks, /CC.
.
Charlie,
Change the the lines without the > and see what it does (if there are no
security prolbems, I think it would work, however I can not see everything
in a message) Dim SqlConnection1 As SqlConnection
SqlConnection1 = New SqlConnection(" Server =
localhost;Datab ase=YourDataBas eName;Integrate d Security = SSPI")
'You had an OleDb connectionstrin g
Dim SQLStatement As String = "SELECT Count(*) FROM student" Dim RecordCount As Integer Dim SelectCommand As New SqlClient.SqlCo mmand (SQLStatement, SqlConnection1) Try SqlConnection1. Open() RecordCount = CInt(SelectComm and.ExecuteScal ar ()) Catch ex As Exception
MessageBox.Show (ex.tostring)
Finally SqlConnection1. Close() End Try MessageBox.Show ("Customers table contains " & RecordCount & " records")
Maybe it will go better, (do not forget to put in the right name of your
database in the connectionstrin g).
I hope this helps?
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bart Nessux |
last post by:
Should an if statement have a corresponding else statement? Or, is it OK
to have an if statement by itself. For completeness, it seems the two
should be together, but from experience I know that a if statement by
itself works just fine. Below is an example:
if x >=0:
DO SOMETHING
Would it be better, or perhaps more complete, written like this:
|
by: Jaime Wyant |
last post by:
I know I've seen this somewhere, but can't seem to google it. Is
there a way to use an alternate statement separator, other than the
default ';'?
jw
|
by: Tom D |
last post by:
I'm rewriting a database interface that our company currently has.
Currently it's using the Pear::DB interface, but we found that that was
introducing a bit too much overhead. I'm rewriting the interface to use
mysqli. Most of what the interface does is to simplify getting results in
the form of arrays (ordered and associative). Most of the code using the
interface used sql queries with placeholders and parameters. For that
reason I'd...
|
by: slogging_away |
last post by:
Hi - I'm running Python 2.4.2 (#67, Sep 28 2005, 12:41:11) on win32, and have a script that makes numerous checks
on text files, (configuration files), so discrepancies can be reported.
The script works fine but it appears that I may have hit a wall with
'if' statements.
Due to the number of checks perfromed by the script on the text files,
(over 500), there are quite a few 'if' statements in the script, (over
1150). It seems that it...
|
by: Fuzzyman |
last post by:
Hello all,
The following is a copy of a blog entry. It's asking a question about
future statements and the built in compile function. I'd appreciate any
pointers or comments about possible approaches.
`Movable Python <http://www.voidspace.org.uk/python/movpy/>`_ supports
running both Python scripts and ``.pyc`` bytecode files. It does this
by compiling scripts to bytecode, or extracting the code object from
bytecode files, and then...
| |
by: Neroku |
last post by:
Hello, i would like to know what the serious definition of statements
and expressions is:
i know an expression are evaluated to a value, i.e:
1 == 2
5+7
foo( 1,2)
and a statement is executed:
break;
|
by: ojorus |
last post by:
Hi!
Some questions regarding the mysqli-extension (php5)
1) Prepared statements: If I understand things right, prepared statements
will give better performance if you make several similar querys. (where you
only change the parameters) But what if you do only ONE query; will it then
be usefull to use prepared statements? Can it actuelly give better
performance NOT to use prepared statements in that case?
2) Are there any DISadvantages...
|
by: Dmitri |
last post by:
Hello!
I have a developer that is playing around with some SQL statements
using VB.NET. He has a test table in a SQL 2000 database, and he has
about 2000 generated INSERT statements.
When the 2000 INSERT statements are run in SQL query analyzer, all
2000 rows are added to the table. When he tries to send the 2000
statements to SQL Server through his app., a random number of
statements do not get executed. But, SQL Profiler shows that...
|
by: Gary Herron |
last post by:
Ohad Frand wrote:
There is no way you can consider 'elif', 'else', 'except', and 'from'
statements. However, as someone pointed out, the kwlist from the
keyword module is the closest thing we can think of to the list you are
asking for.
On the other hand, what's wrong with constructing the list as you did in
your example above?
|
by: Ohad Frand |
last post by:
Hi
Thanks a lot for your reply
I think the main uses for it is to study the language and to see that I
didn't miss anything else or that something is changed from one version
to another.
The keyword module will help me
Thanks again
Ohad Frand
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |