|
PIEBALDconsult:
Yeah it is Access and changing the order of the cmd.Parameters.Add() calls did the trick.
Is there a way to mark this thread as SOLVED?
Thanks !!!
|
|
|
|
|
|
Hi all,
for those of you who have been reading my countless posts on this same question, I think I have solved the problem by binding the database data to the checkedlistbox by using datasource and valuemember properties instead of the other way I was doing it because now the checkedlistbox items now bind by ID. Now in order to make the boxes auto tick depending on the particular employee page I am in(eg.this.EmployeeID), I think all I need help on is this 'if' statement. so far all the boxes are ticking with the following code.
What is the if statement going to be?
<br />
techSkillsCheckListBox2.DataSource = dataSet1.TechnicalSkills;<br />
techSkillsCheckListBox2.DisplayMember = "ProgLanguagesDatabase";<br />
techSkillsCheckListBox2.ValueMember = "TechnicalSkillsID";<br />
<br />
int i;<br />
for (i = 0; i <= (techSkillsCheckListBox2.Items.Count - 1); i++)<br />
{<br />
<br />
<br />
if (FirstnameText.Text.Equals(this.EmployeeID))<br />
{<br />
sql = "Select em.TechnicalSkillsID,t.TechnicalSkills,em.EmployeeID from EmpSkills em, TechnicalSkills t where t.TechnicalSkillsID = em.TechnicalSkillsID and em.EmployeeID = '" + FirstnameText.Text + "'";<br />
<br />
<br />
techSkillsCheckListBox2.SetItemChecked(i, true)<br />
Thank you
Sianny aka Sharny
|
|
|
|
|
The values entered in the UserName TextBox and Password TextBox are compared to the values in the database using the StoredProcedure. And based on that a user is given access to FileManager.aspx or shown an AccessDenied.aspx page. But it does not work that way? I get access to FileManager.aspx page no matter what UserName and Password I put in. Can somebody please tell me what should be the correct code in the Try..Catch method. Cuz that's where my code is wrong. My StoredProcedure works fine. Thanks
protected void btnLogOn_Click(object sender, EventArgs e)
{
SqlConnection sqlconSource = new SqlConnection(ConfigurationManager.AppSettings["cs"]);
SqlCommand sqlcmdSource = new SqlCommand("LogOn", sqlconSource);
sqlcmdSource.CommandType = CommandType.StoredProcedure;
sqlcmdSource.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar, 40));
sqlcmdSource.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar, 10));
sqlcmdSource.Parameters["@UserName"].Value = txtUserName.Text;
sqlcmdSource.Parameters["@Password"].Value = txtPassword.Text;
try
{
sqlconSource.Open();
if (sqlcmdSource.ExecuteScalar().ToString() == "0")
Response.Redirect("AccessDenied.aspx");
}
catch
{
}
finally
{
Response.Redirect("FileManager.aspx");
sqlconSource.Close();
}
And this is my Stored Procedure:
ALTER PROC [dbo].[LogOn]
@UserName varchar(40),
@Password varchar(10)
AS
begin
if exists(select * from UserInformation where UserName = @UserName AND Password = @Password)
begin
select 1 returnflag --UserName is found
end
else
begin
select 0 returnflag--UserName not found
end
end
RETURN
|
|
|
|
|
Finally{} statement will execute no matter what, so you will always redirect to FileManager.aspx.
Also, remove the Catch {} statement if you don't plan to handle any specific exceptions.
|
|
|
|
|
Maybe in that case then I should not use Try..Catch method. What is the other way for me to work with this??
|
|
|
|
|
SqlConnection sqlconSource = new SqlConnection(ConfigurationManager.AppSettings["cs"]);
SqlCommand sqlcmdSource = new SqlCommand("LogOn", sqlconSource);
sqlcmdSource.CommandType = CommandType.StoredProcedure;
sqlcmdSource.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar, 40));
sqlcmdSource.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar, 10));
sqlcmdSource.Parameters["@UserName"].Value = txtUserName.Text;
sqlcmdSource.Parameters["@Password"].Value = txtPassword.Text;
sqlconSource.Open();
if (sqlcmdSource.ExecuteScalar().ToString() == "0")
Response.Redirect("AccessDenied.aspx");
else
Response.Redirect("FileManager.aspx");
sqlconSource.Close();
If you want the Try{} Catch{} because you want to handle a specific SQL exception then do it this way
Try
{
SqlConnection sqlconSource = new SqlConnection(ConfigurationManager.AppSettings["cs"]);
SqlCommand sqlcmdSource = new SqlCommand("LogOn", sqlconSource);
sqlcmdSource.CommandType = CommandType.StoredProcedure;
sqlcmdSource.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar, 40));
sqlcmdSource.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar, 10));
sqlcmdSource.Parameters["@UserName"].Value = txtUserName.Text;
sqlcmdSource.Parameters["@Password"].Value = txtPassword.Text;
sqlconSource.Open();
if (sqlcmdSource.ExecuteScalar().ToString() == "0")
Response.Redirect("AccessDenied.aspx");
else
Response.Redirect("FileManager.aspx");
}
Catch (SqlException e)
{
}
Finally
{
if (sqlconSource.State == ConnectionState.Open)
sqlconSource.Close();
}
|
|
|
|
|
I suggest hashing the password, rather than storing the raw password.
Maybe others have better ideas as well?
|
|
|
|
|
I have a console application running in an infinite loop, it simply parses text files. I need to know how to detect a keypress and then determine which key was pressed. I want the program to terminate upon the pressing of the escape key. Any help would be appreciated, I've been combing the web all over and have found nothing to be helpful.
|
|
|
|
|
ConsoleKeyInfo cki = Console.ReadKey(true);
Console.WriteLine(cki.Key.ToString());
Check the ConsoleKeyInfo.Modifiers collection for the ALT, CTRL, SHIFT keys and you can compare them with the ConsoleModifiers enum.
you can use whatever loop structure you want
do
{
}
while (cki.Key != ConsoleKey.Escape);
You can simply find this information in the MSDN article for Console.ReadKey()[^]
|
|
|
|
|
This will not work. I need to be able to be able to exit at any give time upon the keypress.
|
|
|
|
|
That makes it a little tougher. Which version of .NET are you using? The Console.ReadKey() that Chris suggested is not available until 3.0, unfortunately.
Seems to me that you'll want to make frequent checks for "escape key pressed" within your infinite loop. Some pseudo-code:
while (true)
{
flag = false
get next file
open file
while (not flag)
{
read line from file
if eof
flag = true
else
{
process data from file
if escape key pressed
flag = true
}
}
close file
if flag
exit program
}
The big problem remaining is how to determine if the escape key has been pressed. If you're using 3.0 then Console.ReadKey() should do it. If not, well does it have to be the escape key? The enter key would a lot easier to detect: Console.ReadLine().
BDF
|
|
|
|
|
Iam doing my graduation project and i need to language which is better to dealing with 3d graphics , because i need to build a 3d home from 2d home ( which is drawing by user by this langauge ) and i don't which is better c# or vb.net ??? beacase i need to learn it ...
|
|
|
|
|
Do you have a C/C++/Java background? I'd recommend C#.
Otherwise, I'd say take a few days and play around with both of them and get a feel for the synax because it is different. I'd still recommend C#, but there are solutions for either language.
I've got a book by Apress called "Pro .NET 2.0 Graphics Programming using GDI+. It is pretty good and is a C# book.
Good Luck!
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
For graphics and vector manipulation? You'll tear your hair out trying to use VB.NET for such a thing. Two main reasons:
1. The C# syntax is unambiguous when you're referencing array/matrix/vector indices. In VB.NET, array access and function calls are syntactically identical.
2. Numeric manipulation. VB.NET conceals every rounding, casting, and floating point operation. It tries its best to figure out what you wanted and when precision matters, always gets it wrong unless you're very well versed in the language and know exactly when to cast and when not to.
Obviously either language WILL work for this and depending on your skill level, it may not make any difference. But like the previous poster says - if you've already got a background in C++/Java then C# will be easier to use.
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
|
|
|
|
|
"
If you're a bird be an early early bird.
But if you're a worm, sleep late.
"
-- Shel Silverstien (unless I'm mistaken)
|
|
|
|
|
|
Seems to depend mostly on your background which you'll prefer.
If you have experience with javascript, C++ or Java, you'll be most comfortable with C#.
If you have primarily done nothing but VB and VB script, you'll likely choose... that's right, VB.
If you don't like to be bothered with icky things like type safety and explicit conversion and confusing things like that, you'll be most confortable with VB.
If you like using the occational array, or are interested in readable syntax, or like behavior to follow what you wrote, you'll like C#.
If you like mystical built in 'functions' that won't convert to any other language and exist only for backward compatability, you'll like VB.
If you like pretty code that's nice and easy to read, you'll like C#.
If you like blocky crap with capitalized keywords that require extra typing or letting the IDE dump large chunks of code you may not have wanted, VB's your language.
If you like having no control what-so-ever over code or comment formating, VB's for you.
If you want to be part of the future, C#'s for you.
If you want to be on the stinky end of a sinking ship, VB's what you want.
Like I said, you'll be most comfortable with whatever you're most experienced with. And for the most part, your choice won't affect your options (technically they are both capable of producing the same results). It's really just a personal choice. But I won't taint your decision with my own personal choice.
|
|
|
|
|
BoneSoft wrote: But I won't taint your decision with my own personal choice.
I was astounded by your objectivity! Got my five.
|
|
|
|
|
Eh well, it important to not take sides.
|
|
|
|
|
|
as u r still studying and. i hope that u do most of your course projects in native C or VC or in java..
so C# is more like the above
and it is more popular than vb so i suggest u to stick with c#
|
|
|
|
|
Thanks..
Iam now be very clear to use c# after thier suggestion ...
Thanks very match again..
|
|
|
|
|
Hi,
How can I connect a network printer to a user session via C#???
For example:
I want to connect "\\intranet\phaser" to my current user session and show up as a network-based printer in my local Printers and Faxes folder.
Chris
|
|
|
|
|
You should add the printer to your local
|
|
|
|