Hi,
i used the COUNT function to return the number of rows that satisfy the conditions set. This method works but when i press the load button again, it will still gives me another same set of information. This loop never ends.
C# (VS 2005) Code : - string Cnt = "SELECT Count(1) FROM Module_Repair_Info WHERE StopDate = " + Date + " AND StopTime = " + Time + " AND SerialNo = '" + strSerialNumber + "'";
-
-
if (Cnt != "0")
-
{
-
-
string insertString = "INSERT INTO Module_Repair_Info (" +
-
"FailureNo, XmtrType, SerialNo, [Hardware Rev], [Software Rev], [Firmware Rev], StopDate, StopTime, Stn, Chn " +
-
") VALUES (" +
-
"' ', '" + Model + "', '" + ModuleSerialNumber + "', '" + Hardware + "', '" + Software + "', '" + Firmware + "', '" + Date + "', '" + Time + "', '" + StationNumber + "', " + ChannelNumber +
-
")";
-
-
OleDbCommand myCommand = new OleDbCommand(insertString, myConn2);
-
myCommand.ExecuteNonQuery();
-
-
-
}
I was wondering whats wrong with this code that i had written. Pls help as i spent 2 days on this problem.
Thanks in advance!
7 1428
I believe that Cnt is never going to be "0". Have you displayed the value to see what is going on? Have you tried using count(*) if you want to count the number of records?
hi there,
i tried using Count(*), it still gives me the same string result : "SELECT Count(*) FROM Module_Repair_Info WHERE StopDate = 01-09-2007 AND StopTime = 11:37:52 AND SerialNo = '1746060179'."
I believed that Cnt will not be "0" too but how can i get/return the number of records in this case? I wanted the result to be an integer since it is the number of rows that satisfy the conditions set.
Thanks!
If you want count as an integer, try storing it as an integer and testing that in your condition. Please try this and report back.
i dont think im able to store it as int if i use SELECT statement. I need to use SELECT statement as there are conditions/criterias. That is y i have to use string Cnt = "SELECT .....";
Or is there another way to store it as int?
What happens if you use int Cnt = "Select...";? Here is an article that may reflect your concern about using int rather than string, but as long as strongly type and don't declare as object you should be ok: A Lesson in ASP.NET/SQL Security
Good points about web security too. You may also want to use try/catch blocks.
hi,
i solved the problem. i forgot to execute the SELECT statement and that is y i couldnt get the int value.
Thanks!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jim Hubbard |
last post by:
I have some C# code that is supposed to wrap the defrag APIs and I am trying
to convert it to VB.Net (2003). But, I keep having problems.
The C# code is relatively short, so I'll post it...
|
by: google |
last post by:
I'm trying to implement something that would speed up data entry. I'd
like to be able to take a string, and increment ONLY the right-most
numerical characters by one. The type structure of the...
|
by: dhnriverside |
last post by:
Hi peeps
Ok, so I thought I'd have a go at making a console app in VS2k5... I haven't
written any windows apps for years, let alone dos apps (been web programming)
and I've hit a dumb error...
...
|
by: Satish |
last post by:
Hi Friends
I am little confused about the shadows keyword in VB.NET
could anyone explain with an example about Shadows keyword
Many thanks
Satish
|
by: MP |
last post by:
vb6,ado,mdb,win2k
i pass the sql string to the .Execute method on the open connection to
Table_Name(const) db table
fwiw
(the connection opened via class wrapper:)
msConnString = "Data Source="...
|
by: gunimpi |
last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431
********************************************************
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
wanted...
|
by: Jo |
last post by:
Hi there,
I'm Jo and it's the first time I've posted here. I'm in process of creating
a database at work and have come a little unstuck.....I'm a bit of a novice
and wondered if anyone could...
|
by: pic078 via AccessMonster.com |
last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files)
that remains stuck in task manager after exiting the application - you can't
reopen database after exiting as a result...
|
by: StevenChiasson |
last post by:
For the record, not a student, just someone attempting to learn C++. Anyway, the problem I'm having right now is the member function detAddress, of object controller.
This is more or less, your...
|
by: troy_lee |
last post by:
I am trying to count the total number of units for a given part number
that have a Priority rating of 1. Based upon some research, this is
what I came up with for my query. Access says that I have...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
| |