|
Member 9360291 wrote: how can I contact the author
You can contact the author by posting on the article's message board at the bottom of the article.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
Thanks. I guess I was being stupid, I didn't scroll down the page far enough to notice the message board. Sorry about that (new to site is my only excuse). You can delete my post if necessary.
Doreen
|
|
|
|
|
I am making a project in c# with sql on electoral database that consists of 5 fields ie name, dob, family size, etc etc. Now i'm currently unable to create a storage procedure to edit the data in the database, as am unable to understand how to pass the parameter to receive the value being passed from the program. Searching the net hasn't helped me. Can someone assist me with this?
I have uploaded the project with the database, it can be accessed at https://rapidshare.com/files/1397492724/WindowsFormsApplication2.rar[^]
|
|
|
|
|
|
@Shameel: Absolutely. Sorry, i keep typing the wrong name. :P
@Eddy Vluggen: This is for console applications, and more importantly doesnt edit data. It adds, which i am already able to do. My requirement is to edit the data in a form.
Say, a user loads the data. He finds some error. He makes the change, and clicks on edit data, and its done.
|
|
|
|
|
paddymega wrote: @Eddy Vluggen: This is for console applications, and more importantly doesnt edit data. It adds, which i am already able to do. My requirement is to edit the data in a form.
..does the type of application change the way we talk to a database?
You're adding data by executing an insert statement? Updating is done the same way, with an update statement. Where are you stuck, and what code do you already have?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
CREATE PROCEDURE EDITROW (INT naim, INT aig, INT fmno, INT doab)//these are the parameters being received by the program to the procedure
@age INT,//parameters from the database no wonwards
@name VARCHAR(30),
@familymemno INT,
@DOB int,//end of parameters from the database
AS
UPDATE elecdb
SET naim=@name, aig=@age, fmno=@fammemno, doab=@dob
WHERE @DOB=doab; //update query
RETURN
I just want that the query matches the data in the databse to the data being passed on from the program and update it in the database
|
|
|
|
|
Looks like a reasonable update-statement, and looks like a sproc. I assume that it creates the procedure correctly, or did you get an error?
If the proc is correct, you hook it up to a SqlCommand and set the parameters. You'll probably already have something similar in the insert-statement.
The only thing that bugs a bit is the DateTime that seems to be used as a primary key. I suggest using an identity-field, an auto-incrementing integer. See, the dob might contain a specific time, and that would make it "hard" to find it in the database - a mismatch of a second, and it'll say the record can't be found.
paddymega wrote: I just want that the query matches the data in the databse to the data being passed on from the program and update it in the database
Programming is not an easy task; we're already skipping corners here
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
|
paddymega wrote: Shows error near ) , god knows what error.
If it "shows", then besides God, you could know too what it says. God would speak of a syntax-error here;
CREATE PROCEDURE EDITROW (INT naim, INT aig, INT fmno, INT doab)//these are the parameters being received by the program to the procedure
@age INT,//parameters from the database no wonwards
@name VARCHAR(30),
@familymemno INT,
@DOB int,//end of parameters from the database
AS
UPDATE elecdb
SET naim=@name, aig=@age, fmno=@fammemno, doab=@dob
WHERE @DOB=doab; //update query
RETURN
Are @age, @name etc. part of the parameter-list? If yes, then they should be declared before the ) mark. If not, then they should be declared in the body of the stored procedure, below the "AS" keyword. Something like this probably;
CREATE PROCEDURE EDITROW (INT @naim, INT @aig, INT @fmno, INT @doab)
AS
BEGIN
UPDATE elecdb // this is not a comment, this style will create a syntax error too!
SET name=@naim,
age=@aig,
fammemno = @fmno,
dob = @doab
WHERE dob = @doab;
END
The parameters in the UPDATE statement (the ones with the @-sign) need to match those at the top; the other names are the fieldnames, as defined in the elecdb-table.
I'm at home, on a Linux-laptop. I could open the archive, but there's no Sql Server to run it against.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Oh yes, u're right . My bad :P
The // was added for you guys only, so that the logic could be better viewable for u.
ps: The error's still there. The error is "incorrect syntax near INT, must declare the scalar variable @naim"
|
|
|
|
|
paddymega wrote: The error is "incorrect syntax near INT, must declare the scalar variable @naim"
You could look up the syntax in the documentation[^]. I'm guessing that the parameters need to be declared like in the documentation; the example I gave was not tested, and according to the docs, the parametername should precede the type, like this;
CREATE PROCEDURE EDITROW (@naim INT, @aig INT, @fmno INT, @doab INT)
AS
BEGIN
UPDATE elecdb
SET name=@naim,
age=@aig,
fammemno = @fmno,
dob = @doab
WHERE dob = @doab;
END
If you have more errors, feel free to post them; but please include your actual version of the code, and the error-message; that way you'll get the most (useful) replies.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
|
You're welcome
|
|
|
|
|
Tutorial[^]
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I want to know how to show message from window serviece
|
|
|
|
|
Windows services do not display messages. At all.
A service is something that runs before the user even logs on; that means that there is no user to view your message, and no desktop to display it. The service even runs under a different account; open "Services" from the Admin-section in the config-panel, find your service, look at the second or third tab; that's where the username/password is specified for the account that the service is running under.
The default approach is to create a second app that runs under the users' credential, and have it communicate with the service. I'd recommend TCP/IP for that, but there are more ways to communicate.
Main question here is whether you actually "need" a service. So, what does your service do, and how would a "message" look like?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
ashjassi wrote: show message
If you mean show a messagebox, you don't. Services do not interact with users by design.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
As already stated, a Windows Service is designed to run in the background without a UI and is best suited for tasks that do not need user interaction or even a user session. If at all you have to show a message and interact with the user, you may consider writing a windows application instead of a windows service.
|
|
|
|
|
Windows Service dn't show message. if you show message you can write LOg FIle or you store message to DB
Vijay
|
|
|
|
|
Hello, am new to C# programming, and would like to develop a small application with an in-built scheduler which would for example daily wake up my PC from sleep mode at 8AM and go to sleep mode at 10PM, the same routine going on the next day from Mon to Fri every week.
I do know about using Task Scheduler in Windows 7, but here would like to do it programmatically using C#. Anyone can help me finding the exact codes to perform this?
Thx...
|
|
|
|
|
This[^] is an article that shows you how to put the computer into sleep mode.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
lordrt wrote: I do know about using Task Scheduler in Windows 7,
The task manager is for starting applications; you could write an application that shuts the computer down, but waking it up is a lot more challenging.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
See here: Wake the PC from standby or hibernation[^] - it goes through the process and code pretty well.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
|