|
hey guys
pi have an application.. and i wanna add new user to a database but i want to check if the usernameis already exist in the database.
how can i do it right ?
thanks
Estarta
|
|
|
|
|
use a sql query to check if the name exists in the DB
|
|
|
|
|
Thanks for the reply man.. i have an sql statmenent and its not the problem how can can i handel this when the 'admin' wanna add new user lets say..
when he click 'SUBMIT' it should tells him that the username is in use.
i'll show u a sample if u don't mind
conn.Open();
cmd = new SqlCommand ("select schoolid from users where userid= " + Session["UserID"],conn);
string SchoolID= cmd.ExecuteScalar().ToString();
cmd = new SqlCommand("AddStudent",conn);
cmd.CommandType=CommandType.StoredProcedure;
SqlParameter Name = new SqlParameter("@Name",this.TextBox5.Text);
SqlParameter Username = new SqlParameter("@Username",this.TextBox6.Text);
SqlParameter Password = new SqlParameter("@Password",this.TextBox7.Text);
SqlParameter School = new SqlParameter("@SchoolID",SchoolID);
SqlParameter ParentID = new SqlParameter("@ParentID",ParentDWL.SelectedItem.Value.ToString());
SqlParameter Address = new SqlParameter("@Address",this.TextBox9.Text);
SqlParameter LevelID = new SqlParameter("@LevelID",int.Parse(this.DropDownList2.SelectedItem.Value));
cmd.Parameters.Add(Name);
cmd.Parameters.Add(Username);
cmd.Parameters.Add(Password);
cmd.Parameters.Add(School);
cmd.Parameters.Add(ParentID);
cmd.Parameters.Add(Address);
cmd.Parameters.Add(LevelID);
int i=cmd.ExecuteNonQuery();
Estarta
|
|
|
|
|
Whats the code like in your AddStudent Stored Procedure ?
If you're using a stored proc to do the add it would make sense to do a test in the stored proc if the user name exists, if it does then send a notification back to the application that the user name already exists and that the transaction could not be completed
|
|
|
|
|
well thats cool
i will send you the stored procedure code thanks
CREATE PROCEDURE AddStudent
@Name varchar(20),
@Username varchar(20),
@Password varchar(20),
@SchoolID int,
@ParentID int,
@Address varchar(20),
@LevelID int
as
insert into users values (3,@Name,@Username,@Password,@SchoolID,@ParentID,@Address,@LevelID,NULL)
GO
Estarta
|
|
|
|
|
CREATE PROCEDURE AddStudent
@Name varchar(20),
@Username varchar(20),
@Password varchar(20),
@SchoolID int,
@ParentID int,
@Address varchar(20),
@LevelID int
as
Declare @ExistUser varchar(20)
SELECT @ExistUser = Username from users where username = @username
IF(@ExistUser is Null)
Begin
insert into users values
(3,@Name,@Username,@Password,@SchoolID,@ParentID,@Address,@LevelID,NULL)
end
GO
This is something rough for you to use and give you an idea of what to do.
You'll have to elaborate a bit more on this
|
|
|
|
|
It worked, i dont know how to thank you!!
Where can i elaborate on this. ?
Estarta
|
|
|
|
|
Well you can think about passing back a FAILED or SUCCEEDED values back,
wrap it up in a transaction, there are thousands of possibilities, but you'll find out about them more as you progress.
|
|
|
|
|
Thanks alot
i will try it now.
Regards
Estarta
|
|
|
|
|
Hello
in my project i want to make a series of colors and want to get the hexadecimal of that colors. For eg : starting from the color white (hexa is #000000) i want to increment the hexavalue and want to reach teh hexavalue(#FFFFFF) which is for black.
Please get me idea of how can i do this?
thanks in advance
Hari
|
|
|
|
|
Harikrk wrote: starting from the color white (hexa is #000000)
No, that's black.
Harikrk wrote: i want to increment the hexavalue and want to reach teh hexavalue(#FFFFFF) which is for black.
No, that's white.
Harikrk wrote: Please get me idea of how can i do this?
Make a loop from 0 to 0xffffff. If you want the hex value as a string, format the value using the "X6" format string.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
hello evey one,
can any one explain me how to send an email in an defined format in asp.net on the click event of an button.
rahul saini
|
|
|
|
|
Use the classes in the System.Web.Mail namespace.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
thanks for rplying my post.
can u please send me a sample code for it.
thanks
rahul saini
|
|
|
|
|
public static bool SendMail(string From, string To, string Subject, string Body)
{
try
{
string FileName = @"c:\text.pdf";
MailMessage message = new MailMessage();
message.From = new MailAddress(From);
message.To.Add(new MailAddress(To));
message.Subject = Subject;
message.Body = Body;
message.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("192.168.1.231");
if (FileName != null)
message.Attachments.Add(new System.Net.Mail.Attachment(FileName));
smtp.Send(message);
return true;
}
catch
{
return false;
}
}
|
|
|
|
|
Check out my Article entitled Save an XML File to database and send an email using XSLT
it kind of touches on this and has some code for you to look at
|
|
|
|
|
hai sir/mam
When i close the internet explorer ..want to delete mytable records.....please help me
A.Rajapandian
|
|
|
|
|
u can write ur code in onunload
|
|
|
|
|
in calender_render event, i control the days as:
if (e.Day.isOtherMonth) e.Cell = " "; (sth like that)
so users cant deal with the day of other months.. but when i turn selectmode from day to dayweek, the weeks of other months are seen too..
when calendar is like behind, there is no problem;
- - - - 1 2 3
4 5 6 7 8 9 10
.
.
.
31 - - - - - -
but sometimes it is like
- 1 2 3 4 5 6
7 8 9 10 11 12 13
.
.
28 29 30 31 - - -
- - - - - - -
"-" means, this day is not visible, not clickable..
when selectmode is day, we can see the days of prev or next month.. i hide it.. these days are in the same row with the days of current month, so it is not a problem to see that row..
but if selectmode is weekday, we can see te prev or next week of other months.. there is no day from current day in the row, so there is a empty row.. i want to hide this row too..
other month days are not clickable, those cells are empty and user cant reach.. but when user click on week,, user can select a empty row, even user cant select those days by clickingh on them, he can select them by clicking the week column..
there are 10 types of people in the world, those who understand binary numbers and those who dont..
|
|
|
|
|
Hello
I have a web page with different parts. In some parts of it, user can change the data of that. I put a button to save the data of each part, separately.
The user can enter new data without saving them. But I want to show a message to save them. The message should be shown when user closes the window or click some links.
This message should be shown client side. I know the command window.alert(...). I do not know in which JavaScript event I should show that to support every option of page transfer.
Please instruct me or offer me a different way.
Thanks
Rastgar
|
|
|
|
|
either <body onbeforeunload="functionName()" >
or <body onunload="functionName()" >
function functionName()
{
alert('pls save');
window.event.returnValue = false;
window.event.cancelBubble=true;
}
|
|
|
|
|
Thanks for your help.
Your code works very well. But when i use it, after alert 'pls save', I have another alert:
"Are you sure you want to navigate away from this page?
false
Press ok to continue, or cancel to stay on the current page."
it happens after code:
"window.event.returnValue = false;"
I don't want this alert to be shown. What should I do?
Thanks
Rastgar
|
|
|
|
|
Not possible to stop browser to close in JS. So u have to go with that extra alert.
|
|
|
|
|
Hi all,
I made a button in a masterpage and it works correctly when clicked.I want to know if there is any way to submite this button by pressing Enter from keyboard,because what happens is that the page is posted without submitting the button because it's not in the same page.
thanx
|
|
|
|
|
It is on the same page. The master page and the content page together form a web page. When the page reaches the browser, it's just a single page.
Make sure that the button is the first button in the code of the form, and enter will work so submit it.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|