|
hi there...
I'm writing a query to check whether a user is already existing in the database so i can avoid re registering him.
i was trying to take the count of users having the same details. if its zero the user doesn't exist if one then he already registered.thats were i ran into problem. One of my fields in the form is a dropdown list. ie if the user gives the same data for the all other fields and choose a different option in the dropdown list the user can be registered as a different user. i want to avoid this. how to do?????
This is my query
create procedure sp_chkUnique
{
@rrf_id bigint,
@cand_name varchar(100),
@cand_fathername varchar(100),
@cand_dob varchar(50),
@gender varchar(50),
@cand_email varchar(200),
@cand_verification varchar(50),
@pincode varchar(10)
}
as
select count(rrf_id)
from cm_rm_tb_042
where rrf_id=@rrf_id and
cand_name=@cand_name and
cand_fathername=@cand_fathername and
cand_dob=@cand_dob and
gender=@gender and
cand_email=@cand_email and
pincode=@pincode;
its the @cand_verification field thats coming from a dropdown list.i cant jst avoid checking it either...
plz help me
|
|
|
|
|
You aren't using @cand_verification anywhere in the select, so you should be OK. Basically, if all of the other information is present then @count will return none-zero. The rule here is that you can prevent duplicates by checking those fields that you consider will make it a duplicated record, and exclude those fields that would make it unique.
|
|
|
|
|
Thanks for replying...
i didn't use the @cand_verification coz i dnt knw how to use it to check the existence of the user.
i cant jst leave that field out. i need to check that condition too.
plz help
|
|
|
|
|
HI all,
I have a windows application which runs a process,
I am updating database column "Status" with Processing when the application is running, and on completion I update it with Staus="Completed" or in case I close the application
I update db with Status="Interupted" .
I have problem that in case while proces is running, power supply or system turns off, the db Status="Processing", but in actual it is interupted.
How will i update?
Please help.
|
|
|
|
|
well I think there's really no way u can cope for power failure in such a case. i mean if there is no electricity, how is the Db supposed to get the status changed to 'interrupted'.
you can have two status values though, one 'incomplete' (by default) and the other 'completed'
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
Gokul Harsh wrote: HI all,
I have a windows application which runs a process,
I am updating database column "Status" with Processing when the application is running, and on completion I update it with Staus="Completed" or in case I close the application
I update db with Status="Interupted" .
I have problem that in case while proces is running, power supply or system turns off, the db Status="Processing", but in actual it is interupted.
How will i update?
If I were you, I'd use a transaction and two updates to do this. I would update the record to Interrupted and then create a transaction in which I updated the same record to Processing. Then, if the server crashes, once the server restarts the database transaction manager will rollback the uncommitted transactions which would revert the record back to the Interrupted status.
|
|
|
|
|
oh yes that's good
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
Thanks. I liked it.
|
|
|
|
|
hi
i had created as SP to delete the record using where condtn.if the record doesnt exists the SP will throw an error as "No such record found" and return 0 .
But my c# code gets -1 rows affected from the sql.its ok.
My problm is how to get the "No such record found" from sql to c#.
ALTER PROCEDURE SP_deleteUserMaster<br />
@LoginId nvarchar(30)<br />
AS<br />
begin<br />
set nocount on<br />
declare @ncnt int<br />
select @ncnt=(select count(*)from UserMaster where LoginId=@LoginId)<br />
if (@ncnt>0)<br />
<br />
begin<br />
DELETE FROM UserMaster WHERE LoginId=@LoginId<br />
end<br />
else<br />
raiserror('No record found',10,1)<br />
end<br />
RETURN<br />
senthil
|
|
|
|
|
Hello!
Put this line after raiserror sentense
select 'No record found'
And also into your code
string result = (string)CommandName.ExecuteScalar();
I am not sure but may be this will help you.
Regards..
Keep Smiling
|
|
|
|
|
thank u shah
i ll check and reply
rgds
kssk
|
|
|
|
|
Hi,
I have a problem in writing a query in SQLSERVER 2000. I have 2 tables tblemployees and tblbank. Fields in the tables
tblemployees tblbank
empid empname paymode empbankid bankid bankname
empbankid in tblemployees is a foreign key of bankid in tblbank.
some employees will have paymode as cheque or cash. I that the bankid field in tblemployees will be null.
Now I want a result set as below
empid empname paymode bankname
for this i have written a query like below
select tblemployees.empid,tblemployees.empname,tblemployees.paymode,tblbank.bankname from tblemployees,tblbank where tblemployees.empbankid=tblbank.bankid
The Actual problem comes now. This query is not retrieving employees who have bankid as null. For employees who do not have bank id the bank name should be displayed as null and the remaining fields should be displayed as it is.
Please help me with a solution for this problem
|
|
|
|
|
Perform a LEFT JOIN betweeb tblemployees and tblbank. Rows on the left-hand side of the join will be preserved, so all employees will be listed regardless of whether they have bank details.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi all
i need to retrieve values from two tables which is common....
EX:-
Table1 Table2
Itemno ItemName SNo ItemName
1 pen 1 Pencil
2 paper 2 pen
here i should get the result as
pen
paper
pencil
how to write a query for this?...
can anybody help me?
|
|
|
|
|
Hello Sandhya!
Try this.
select ItemName from Table1 <br />
union all<br />
select ItemName from Table2
Keep Smiling
|
|
|
|
|
|
I'm upgrading classic asp to asp.net. Through out the code I see whenever there is an insert to the database it is done in two steps. First it does an insert with minimal fields to get an id of the new record then the record is updated on subsequent lines of code.
Doesn't it make a sense to do the whole operation in a single insert? Is there a valid reason or advantage doing it in two steps?
/* I can C */
// or !C
Yusuf
|
|
|
|
|
Yusuf wrote: Doesn't it make a sense to do the whole operation in a single insert?
Yes.
Yusuf wrote: Is there a valid reason or advantage doing it in two steps?
So the original author doesn't need to learn how to do it in one step.
|
|
|
|
|
Looks like a case of code that was written for testing was then changed to live code.
With the information you have provided I can see no reason to need to do this.
The only time it may be useful is in an OLTP system where thousands of users need to create records at high speed and recover the id (for call logging purposes for instance), as you say, before inserting a large amount of data in a row.
Regards
Guy
You always pass failure on the way to success.
|
|
|
|
|
HI could anyone tell me how to find all the disabled trigers in the database?
Mujtaba
"If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
|
|
|
|
|
This should help you Clickety
You may need to make a few changes but the general gist of it is all there.
Regards
Guy
You always pass failure on the way to success.
|
|
|
|
|
im working on windows applicaction and i want to support th ehijri calnder (islamic calnder)
the year 1428 will be 2007.
but when im trying to inser new filed gave me out of range (1765<)
here is some examples:-
declare @x datetime
set @x= convert(datetime ,'01/01/1428',131)
print @x the result is ===> "Jan 19 2007 12:00AM"
convert from hijri to gregorian worked well
but
declare @x datetime
set @x= convert(datetime ,'01/01/1482',101)
print @x the result is ===>
"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
" tha means cant convert from hijri to gregorian
so plz what is the best method for me to accept the both pc calender setting for my application.
regards
|
|
|
|
|
Here is a clue.
Try both of these queries:
<br />
declare @x datetime<br />
set @x= convert(datetime ,'01/01/1428',131)<br />
print @x <br />
<br />
print convert(datetime ,'01/19/2007',101)<br />
Regards
Guy
You always pass failure on the way to success.
|
|
|
|
|
hi all,
i m trying to store the path of file in mysql database using vb.net. This path contains "\" but Mysql database does not store it. Also when i directly edit or enter(or using php) the field in database and insert "\" in database field then it stores backward slash.
anybody have idea where i m wrong. I am using MySql.Data.dll(ver. 5.1.2.2) for connect .net to MYSQL ?
any help will be greatly appreciated.
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Google for 'escape characters' and you will find out how to do it
|
|
|
|