C Sharp :: Checking If ID And Reg Already Exists
Jun 5, 2013
I have this table Profile which has fields with user_Id and regNo and I want to check first if id and email are already exists before proceed to inserting datas. In my codes, I am able to validate only one row (either id or reg number), but if I am going to validate the two of them, it gives me an error, saying "Must declare the scalar variable @userid". I dont know if it is with my select that is wrong or something in my codes
SqlConnection con = new SqlConnection("Data Source=GATE-PCSQLEXPRESS;Initial Catalog=dbProfile;Integrated Security=True");
con.Open();
SqlCommand cmdd = new SqlCommand("select * from Profile where user_Id = @userid AND RegNo = @reg", con);
SqlParameter param = new SqlParameter();
[Code] .....
View 3 Replies
ADVERTISEMENT
Apr 30, 2012
How to validate if the item you want to add in the cart is already exists in listView items? for example I already add CH001 which is the productId of Chocolate strawberry, then I accidentally add again that product Id and I what I want is that it should not be accepted on my listview again because CH001 is already on my cart.
View 5 Replies
View Related
Nov 27, 2014
I have a dynamic storage class based on a vector. The elements of this class shall be addressable via a string.
I have something like the following:
StorageClass* test = new StorageClass();
while(notEnd) {
test->setValue("name3", 3);
test->setValue("name2", 4);
[Code] ....
The Storage class is implement with a vector having to attributes per entry, the first one is name the second one is value. If the setValue function is called, Igo through the whole vector to find the correct item via the name and than i set the new value.
At the end of the loop i want to write out the data into a comma separated value file (*.csv). This shall be done generic by the writeLineToFile() function of the StorageClass.
As a want the columns in csv file to be sorted in a specific way a thought about a preInitalisation routine at the beginning of the program which builds a the vector with all possible entries as something like this in order to define a specific output order.
test->assign("name1");
test->assign("name2");
test->assign("name3");
So my outputfile should look like this:
name1;name2;name3;
5;4;3;
I now have 2 places in the code where i write down the "fieldnames".
I was wondering if there is a possibility to check if the fields called by the setValue function were first aranged in the vector by the assigned() function before or bettwer while compiling the programm.
I thought about MAKROS with #define XYZ and #ifndef XYZ #error to do though, but currently i reached a dead end and find no solution for my problem.
View 4 Replies
View Related
Apr 25, 2014
I have to check whether or not a record exists in a join and if not ignore that user but still load all the other information for that user
var db = Simple.Data.Database.OpenNamedConnection("sqlConn");
var expr1 = db.PON_APP_USERS.STATUS == 1;
var sUsers = db.PON_APP_USERS.FindAll(expr1)
.Select(
db.PON_APP_USERS.USERKEY,
db.PON_APP_USERS.LAST_NAME,
db.PON_APP_USERS.FIRST_NAME,
[Code] .....
View 8 Replies
View Related
Sep 19, 2013
I usually check if a bit is set using:
Code: bit = (number >> n) & 1; where `n` is the bit I want to check...
But I came across a stackoverflow answer saying:
bit = number & (1 << x); will not put the value of bit x into bit unless bit has type _Bool (<stdbool.h>).
Otherwise, bit = !!(number & (1 << x)); will..
So why is this? why the double !?
View 5 Replies
View Related
Nov 4, 2013
Everything seems to be correct from my perspective. heres the program: Code: /*c program to check whether a string is palindrome or not*/
#include<stdio.h>
#include<string.h>
int main(void) {
char str[30];
int i,j,flag=0;
[Code] .....
View 1 Replies
View Related
Dec 8, 2013
The reason being is that it says that my program is right
Code:
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define NFlights 10
struct date {
int month;
int day;
int year;
int hour;
int minute;
[Code] ....
View 6 Replies
View Related
Jun 15, 2013
Q. In context of C language syntax checking, which of the following can be modeled using Finite Automata?
(A) Detecting proper termination of an instruction.
(B) Detecting balance of parentheses.
(C) Detecting initialization of a variable.
(D) None of the above.
View 4 Replies
View Related
Jan 31, 2015
I am new to C++ , i want to know how to check if a key with modifier is pressed.
When I use GetAsyncKeyState() it gives me error identifier not found.
View 1 Replies
View Related
Aug 4, 2013
I think I may have found a new way of checking for 3d polygon collisions, but I'm not sure. The method involves...
1. finding the planes that the primitives lie on
2. finding the line where the planes intersect
3. if both polys have points on both sides of the line AND have points that overlap on the 1d space of the line, then they intersect.
I have some half done code testing this, and so far it seems to be sound and fairly fast. These are some average time-tests done on my machine for each part:
1. 30 microseconds (both)
2. 7 microseconds
3. TBD
View 5 Replies
View Related
Jun 17, 2014
I have a question, how can I check if a program is running using c++? For example
if (notepad.exe is running) {
.... ..... ....
View 3 Replies
View Related
Jul 20, 2014
How would I go about checking for deallocated memory?
For example, let's take this into consideration:
// Unsigned 32-bit / 64-bit integer: uint32, uint64
uint32* Pointer = new uint32[ Size ];
uint64 MemAddr = ( uint64 ) Pointer;
delete[] Pointer;
The above code would proceed to create a new array, store it in a pointer and retrieve the memory address of the array before finally deleting the array.
So let's assume we re-build the pointer and try to access the now deallocated array:
Pointer = ( uint32* ) MemAddr;
Pointer[ 0 ] = 0;
Based on the above snippets of code, how would I check "Pointer" after rebuilding the memory to check if the rebuilt memory has actually been deallocated. Without a check we'd get an exception error.
A bit of detail on why I am trying this:
Before thinking up how to do this, I was storing the addresses in a list and check the list for the addresses to see if they existed or not. However this requires an O(n) search, which isn't exactly what I am wanting. So instead if I used a check for deallocation method, I can go for an O(1) time check and reduce the total time it would take to check for memory allocation/deallocation.
View 11 Replies
View Related
Jan 23, 2014
I have created a prompt which prompts the user for an integer and I have set up a loop to check for if it is an integer or not. My "bug" is that a user can enter an "integer" and "space" and "enter" and it does not give any error and assumes that "All is FINE!". I have gotten the value from the ascii table of 'SPACE' and put it as a check in my parameter of while, but it does not work.
Here is my code:
int x, y, boolean, i;
char buff[256];
printf("Enter the first integer value: ");
scanf("%s", buff);
i = 0;
boolean = 0; //initializing our boolean var that will eventually decide if we have an error or not
[code]....
View 4 Replies
View Related
Mar 6, 2014
Suppose you have a templated class, such as
template <typename T>
class Matrix {
// some stuff and some methods
};
and let's say that you have some methods that need to do some type-dependent stuff, like, for example,
template <typename T>
Matrix<T> Matrix<T>::transpose() const {
// get this->rowCount, this->columnCount
// create a Matrix that has rowCount amount of columns and columnCount amount of rows
// copy (*this)[j][k] to theMatrix[k][j] (for all of the entries in *this)
// if the entries are complex, take the complex conjugate of them all
}
Would it be good practice to check explicitly for the typename parameter (or is this, somehow, defeating the purpose of templates)? std::cout << "I know that this is a design question, but it needs to be asked... ";
View 1 Replies
View Related
Mar 1, 2015
I'm playing around with parts of code and am coming across some errors. Most of my concern is related to strtok(). I've used it before but with a char* named token. I used a while loop to continuously check whether token was equal to NULL. In the following code, however, there aren't any checks. I was wondering if that is why this code prints (null) while running. Also, I would like to know if it is possible to read input like this code attempts to do - assigning tokens to each variable one after the other.
The format of the input:
Zucchini, Squash, pound
Yellow, Squash, pound
Tomatoes, Ugly Ripe, each
#include <stdio.h>
#include <stdlib.h>
[code]....
View 3 Replies
View Related
Oct 13, 2013
Assuming I have a list of pointers to a generic type T:
#include <vector>
//...
list<T*> myList;
Now assuming I want to go on the list, and if T's type is matched to the type I'm looking for, then cast it to this type and do something. List shown here:
list<T*>:: const_iterator iter= myList.begin();
for(; iter!=myList.end(); ++iter){
if( typeid(*iter)==typeid(Something*)) //RUN-TIME ERROR
dynamic_cast<Something*>(*iter)->DoSomething();
}
how do I fix this run-time error?
View 1 Replies
View Related
Feb 14, 2014
#include <iostream>
using namespace std;
int main(){
int x;
cout << "Enter character:";
cin >> x;
[Code] ....
If i type in:
+
How come it says that "this is not addition?
View 5 Replies
View Related
Mar 29, 2012
How do I check for ldconfig in a makefile? This makefile errors because it tries to run ldconfig, even though OS = Darwin
Code:
ifeq ($(SHARED),1)
install: banner install_headers $(lib_target)
@echo "Install shared library"
cp -f ./$(lib_target) $(inst_path)
cd $(inst_path) ;
[Code] ....
Errors
Code:
/bin/sh: -c: line 0: syntax error near unexpected token `Darwin,Darwin'
/bin/sh: -c: line 0: `ifneq (Darwin,Darwin)'
make: *** [install] Error 2
make: ldconfig: No such file or directory
make: *** [uninstall] Error 1
View 3 Replies
View Related
Dec 21, 2012
To calculate line slope I am using formula ,
line_slope = (meanxy - (meanx * meany)) / (meanyy) - (meany * meany));
All the variables are floats.
How to check whether the denominator .. (meanyy)- (meany * meany)) is zero ? Cause its float.
can I check with ..
float f1 = (meanyy) - (meany * meany) ;
if (f1 == 0.0) ..
Will this work surely ? I am using this formula in project based on winXP but it survived. As soon as I ported the code on DPMI based code , I observed a system hang after some time if all the points I supply are (0,0) while drawing a line.
View 3 Replies
View Related
Apr 9, 2013
I' used to check if my streams are properly opened with a simple:
Code:
if (!file)
std::cout<<"Error message";
However I just realized this is only a valid test if they are initialized with a wrong string and when I tested it:
Code:
int main() {
ifstream f_one("input.txt");
ifstream f_two("not_a_file.txt");
ifstream f_three;
[Code] ....
I didn't get the f_three error message, only the f_two.
how should I check my streams in order to prevent this?
View 6 Replies
View Related
Mar 9, 2013
I am using Dev C++ on a windows computer.
In my code, the user enters the name of a city, and then according to what city it is, the program displays the coordinates of that city
I can't find a way of figuring out and checking which city the user has entered so the code can displays its appropriate latitude and longitude.
View 9 Replies
View Related
Oct 15, 2012
is there a tool to find all functions and classes in an assembly?
View 3 Replies
View Related
Feb 22, 2013
while bytesremaining >=8 do something;
if bytesremaing <8 then something else .
I am new and don't know how to code for this.
View 2 Replies
View Related
Nov 23, 2013
wrote this program to check if a string is an integer. It checks for + or - sign at the front of it, but it spat out some errors.I think I broke it.Here is the code:
Code:
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
int getInteger(char*);
int main(void) {
char str[99];
int x;
}
[code].....
View 2 Replies
View Related
Mar 23, 2014
Code:
#include <stdio.h>
#include <stdlib.h>
#define MAX_READ 2
int main( ) {
char * secret = "abecedarium consisting This is a string literal!";
[Code] ....
I am trying to test what happens in the sscanf converted types (command and string) if they are smaller, i got surprised that the printf worked, so i dont know why.
this code is just a test for what i want to do, what i really want to do is for example: i have this string from the stdin which must have the following format:
connect name.surname
So I need to check the cases when it is not the input that i want, namely if the name.surname is for example bigger than 30 chars. and also if it has the abecedary characters from the ascii...
View 2 Replies
View Related
Jul 23, 2014
If I want to check if all the variables are pairwise distinct, i.e. they're all different. Here's a code I wrote to do this:
if (s!=e&&s!=n&&s!=d&&s!=m&&s!=o&&s!=r&&s!=y&&e!=n&&e!=d)
if (e!=m&&e!=o&&e!=r&&e!=y&&n!=d&&n!=m&&n!=o&&n!=r&&n!=y)
if (d!=m&&d!=o&&d!=r&&d!=y&&m!=o&&m!=r&&m!=y&&o!=r&&o!=y&&r!=y)
Is there perhaps some function that would let me do this in a lot shorter way, i.e. something like this (that would act the same way my other code does): if (different(s,m,d,e,o,n,y))
What is the best way you can think of? Without having all those variables in an array. Otherwise it wouldn't be so hard to create a function.
View 8 Replies
View Related