|
If you didn't write the function (i.e. if you can't change the source code), you cannot change what exceptions it throws, all you can do is throw whatever seems appropriate to you based on what the function returns.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If you have written the function, to throw an exception you do this:
<br />
private void someFunction()<br />
{<br />
throw (new Exception());<br />
}<br />
But adjust the type of exception accordingly.
Is that what you wanted?
Hope that helps.
|
|
|
|
|
'throw (new Exception());' must be inside the function block:
openFileClicked() { throw (new Exception()); }
|
|
|
|
|
I am doing a project for school I have to wirte a code for a login page if the user enters a vaild username and passwrd is should tell me how much is in my back accouont if the login is invalid it should say invalid password I am using visual studio can anyone help me
Heather
|
|
|
|
|
Hi, Heather. I'm sure tons of people here can help you, but first you need to ask a question. Right now, this looks suspiciously like 'do my homework for me', which is a whole different story. Is this a windows application ? That is, do you need a login *dialog*, or will the login just appear as text in a scrolling window ? If the former, then you need to start by creating a login dialog. If the latter, then the job is trivial, you just need to accept input, check a password/username combo and print some number. In either case, you should start doing your own homework, and ask some questions when you're stuck on specifics, and have some code to post so we can see what's going on and help from there.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
it is a windows application I am not asking anyone to do my homework I am asking for a helping hand to get it started, I am not sure how to get it to look for the correct usernames and passwords
Heather
|
|
|
|
|
this is what I have so far but I know it is not right
cant figure out how to fix it
int lgflg = 0;
SqlConnection conn =
new SqlConnection( ConfigurationSettings.AppSettings["DSN"].ToString() );
SqlCommand cmd =
new SqlCommand("SELECT ID From [User_tbl] Where Pass = '" + Pass.Text
+ "' And Login = '" + Login.Text + "'",conn);
conn.Open();
SqlDataReader myReader = cmd.ExecuteReader();
while (myReader.Read()) {
lgflg = 1;
}
myReader.Close();
conn.Close();
if (lgflg == 1) {
Response.Redirect("default.aspx");
}
Heather
|
|
|
|
|
To make things a little easier to read you could rewrite it like this:
<br />
bool validAccount = false;<br />
<br />
SqlConnection conn = new SqlConnection( ConfigurationSettings.AppSettings["DSN"].ToString() );<br />
SqlCommand cmd = new SqlCommand("SELECT ID FROM User_tbl WHERE Pass = \'" + Pass.Text + "\' AND Login = \'" + Login.Text + "\'",conn);<br />
<br />
conn.Open();<br />
<br />
if(cmd.ExecuteNonQuery() > 0)<br />
{<br />
validAccount = true;<br />
}<br />
<br />
conn.Close();<br />
<br />
if (vaildAccount) <br />
Response.Redirect("default.aspx");<br />
else<br />
Response.Write("Authentication Failed.");<br />
Were you getting an error with the code you wrote It seems ok.
|
|
|
|
|
You can use Hashing algos to create user passwords and compare your login infos with the hashed ones.
Enjoy coding
|
|
|
|
|
This is awful advice for the posted homework question.
1!
|
|
|
|
|
Hi! I really don't know why I get this error--> System.Runtime.InteropServices.COMException everytime i try to import excel files into my application. When I tried using the sample code directly calling it from the main function, it worked. But when I put the sample code in an area where the user will be the one to choose if he/she wants to import excel files or not, I have that error...I really don't understand why... Thanks!
|
|
|
|
|
Hello everyone,
Greetings from Brazil! Please help! I have a DataGridView in a windows form with three columns:
Column1 is TipoComboBoxColumn
Column2 is QuantidadeColumn
Column3 is SementeComboBoxColumn
I need the SementeComboBoxColumn to display values according to the value I select in the TipoComboBoxColumn.
How do I go about accomplishing that? The code below works in part, BUT when I'm editing the value of SementeComboBoxColumn, the other values in this column disappearin the other rows.
private void tabBAdetDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (tabBAdetDataGridView.Columns[e.ColumnIndex].Name == "EspecieComboBoxColumn")
{
this.tabSementesTableAdapter.FillByTipo(this.sascrDataSet.tabSementes, tabBAdetDataGridView.Rows[e.RowIndex].Cells["TipoComboBoxColumn"].Value.ToString());
this.EspecieComboBoxColumn.DataSource = this.tabSementesBindingSource;
this.EspecieComboBoxColumn.DisplayMember = "Semente";
}
else
{
this.tabSementesTableAdapter.Fill(this.sascrDataSet.tabSementes);
this.EspecieComboBoxColumn.DataSource = this.tabSementesBindingSource;
this.EspecieComboBoxColumn.DisplayMember = "Semente";
}
}
Thanks in advance,
JC Carmo
|
|
|
|
|
I need help using windows hooks. Specifically, I want to hook the actions in a program I did not write. In testing, I set up a program that displays its ThreadID. I then try to install a Hook on that ID but it does not work.
|
|
|
|
|
Hi,
Is it impossible to embedd resources into other namespaces than root? The problem is that I cannot find my resourses from classes that do not belong to the default namespace. Please help.
Thanks.
Magnus
|
|
|
|
|
Uh, change the filename form SomeFile.txt to SomeNamespace.SomeFile.txt ? That's the way i always do it...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
Thanks Marc!
But...then I can't put the resources in subfolders (in Solution Explorer), since the resource name gets wrong, i.e., <subfolder_name>.<namespace.original_filename>, with the namespace after the subfolder name. E.g., then I can't access the resource with
bmp = new Bitmap(this.GetType(), filename);
which otherwise would be a convenient and natural way.
Well, maybe I have to live with this, but I think it's strange that you can't assign resources to namespaces in the same way as classes. I mean, it's all about having structure and order in your work.
Magnus - Javaman
|
|
|
|
|
Huh, i don't get it. The folder a file is in has nothing to do with the name of a file as a resource, just like code files. Something can be in a folder a\b\c\d\e\img.bmp , but as a resource it's still just img.bmp .
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
i've created a custom control for my application made by a no border form with a label and an imagebox inside.
I've a very long list of these controls to show so i need to add at my application a VScrollbar.
How can i scroll these custom controls pixel for pixel?
Do i've to create all of these or create and deleting just what it is showed everytime i scroll?
|
|
|
|
|
1>How do we read metadata of various file formats using c#....
2> Like i want to read from an Mp3 file the details of artist,album etc
3> from an word file the author,etc etc
|
|
|
|
|
1) You need a description of the file format, one good source is here. You can then use a StreamReader , BinaryReader or other .NET classes to read the data you want
2) The ID3 tag version 1 can be easily read by moving the file pointer to END-128 bytes and then read the 128 bytes. If the first 3 bytes are "TAG", then there is a ID3V1 tag. The ID3V2 tag more complex though. You can use a StreamReader for this purpose.
3) see 1)
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi all
I have main form and this form mdi container and I add another form to customize controls colors in the main form
How can I send new colors to main form????
Thanks for help
|
|
|
|
|
To get a reference to your parent use the following code:
((ParentName)this.MdiParent) where ParentName is the class name of the Mdi Parent.
|
|
|
|
|
and how can i call the controll it self, and if it possible to call control without being public static????
|
|
|
|
|
public static void Detect Edges(Bitmap original, ref Bitmap modified, Color c, int noise)<br />
{<br />
Graphics g = Graphics.FromImage(original);<br />
for(Int32 x = 0; x < original.Width; x++)<br />
{<br />
for(Int32 y = 0; y < original.Height; y++)<br />
{<br />
if(x > 2 && y > 2)<br />
{<br />
try<br />
{<br />
Color current = modified.GetPixel(x , y);<br />
Color right = modified.GetPixel(x + 1, y);<br />
Color left = modified.GetPixel(x - 1, y);<br />
<br />
int total Current = current.R + current.G + current.B;<br />
int total Right = right.R + right.G + right.B;<br />
int total Left = left.R + left.G + left.B;<br />
<br />
if(total Current > (total Left + noise) || total Current > (total Right + noise))<br />
{<br />
modified.SetPixel(x - 1, y, Color.White);
}<br />
else if(total Current > (total Right + noise))<br />
{<br />
modified.SetPixel(x + 1, y, Color.White);
}<br />
else<br />
modified.SetPixel(x, y, Color.Black);
<br />
Color upon = modified.GetPixel(x, y - 1);<br />
Color down One = modified.GetPixel(x, y + 1);<br />
<br />
int totalUpOne = upOne.R + upOne.G + upOne.B;<br />
int totalDownOne = downOne.R + downOne.G + downOne.B; <br />
<br />
if(totalUpOne > (total Current + noise)) <br />
{<br />
modified.SetPixel(x, y - 1, Color.White);<br />
}<br />
else if(totalDownOne > (total Current + noise))<br />
{<br />
modified.SetPixel(x, y + 1, Color.White);<br />
}<br />
else<br />
modified.SetPixel(x, y, Color.Black); <br />
<br />
<br />
<br />
<br />
Color uplift = modified.GetPixel(x - 1, y - 1);<br />
Color downright = modified.GetPixel(x + 1, y + 1);<br />
<br />
int totalUpLeft = upLeft.R + upLeft.G + upLeft.B;<br />
int totalDownRight = downRight.R + downRight.G + downRight.B;<br />
if(totalUpLeft > (total Current + noise))<br />
{<br />
modified.SetPixel(x - 1, y - 1, Color.White);<br />
}<br />
else if(totalDownRight > (total Current + noise))<br />
{<br />
modified.SetPixel(x + 1, y + 1, Color.White);<br />
}<br />
else<br />
modified.SetPixel(x, y, Color.Black); <br />
<br />
Color upright = modified.GetPixel(x + 1, y - 1);<br />
Color down Left = modified.GetPixel(x - 1, y + 1);<br />
<br />
int totalupRight = upRight.R + upRight.G + upRight.B;<br />
int totalDownLeft = downLeft.R + downLeft.G + downLeft.B;<br />
if(totalupRight > (total Current + noise))<br />
{<br />
modified.SetPixel(x + 1, y - 1, Color.White);<br />
}<br />
else if(totalDownRight > (total Current + noise))<br />
{<br />
modified.SetPixel(x - 1, y + 1, Color.White);<br />
}<br />
else<br />
modified.SetPixel(x, y, Color.Black); <br />
}<br />
catch(System.ArgumentException)<br />
{<br />
<br />
}<br />
}<br />
}<br />
}<br />
<br />
<br />
}
in this method, there are four arguments
1- input picture
2- output picture (that is modified)
3- color
4-noise
this method making edge detection for the face
i want to passing a picture to this method and having the modified picture,.........how can this task accomplished
i will be grateful if the answer be in code
thanks to u in advance
haitham
-- modified at 7:49 Sunday 19th February, 2006
|
|
|
|
|
So you have a method, and you can't even figure out how to call it? Don't you think that face recognition might be something that is far beyond your current skill level?
The method that you are showing is not possible to call anyway. A method name can not contain a space character.
---
b { font-weight: normal; }
|
|
|
|