|
i am trying to write this code in C#.i have a problem with Err.Number
how can i get error number in C#.
Error number is always Zero but in VB it's show the correct Error Number !!
VB.net
On Error GoTo ERROR_HANDLER
Dim TermID As Int32 = Convert.ToInt32(txtTermId.Text)
Dim EmpNum As Int32 = Convert.ToInt32(EmployeeList.SelectedItem)
objFuncs.LogIn(TermID, EmpNum, "", "")
StatusBar1.Text = "You successfully logged in with Employee " & EmpNum
ERROR_HANDLER:
MessageBox.Show(Err.Number.ToString())
Select Case Err.Number And &HFFF
Case ErrCOM_InvalidEmpPassword : MsgBox("Invalid password")
Case ErrCOM_CouldNotFindEmployeeFromId : MsgBox("Could not find employee from ID")
Case Else : MsgBox(Err.Description)
End Select
C#
try
{
int TermID = Convert.ToInt32(txtTermId.Text);
int EmpNum = Convert.ToInt32(EmployeeID.Text);
objFuncs.LogIn(TermID, EmpNum, "", "");
richTextmsg.Text += "You successfully logged in with Employee " + EmpNum;
}
catch
{
MessageBox.Show(Information.Err().Number.ToString());
switch(Information.Err().Number & 4098)
{
case ErrCOM_EmpLoggedOnOtherTerm:
MessageBox.Show("The employee is logged on to another terminal", 0, null);
break;
case ErrCOM_SomeoneAlreadyLoggedIn:
MessageBox.Show("Someone else is already logged on to this terminal", 0, null);
break;
}
|
|
|
|
|
Get the exception object in the catch statement:
catch (Exception ex)
The exception object contains information about the exception.
You can even catch only specific exceptions, or handle different exceptions separately:
try {
} catch (FormatException ex) {
} catch (Exception ex) {
} catch {
}
The Err object is a leftover from VB6, in VB.NET it's not much more than a wrapper around an exception object. You can use Try...Catch in VB.NET, just as in C#.
---
b { font-weight: normal; }
|
|
|
|
|
Hello dear programmers,
I am developing a project which require xml transfer from pc tp pda and vice versa over seial port.
i have no idea how to do it.can any body send me sample code
of serial communication between the two.
i'll be very greatful to you.
Regards
Ahsan Ullah
|
|
|
|
|
RS232 Communication can be accomplished using System.IO.Ports.SerialPort (.NET 2). As to the actual transferring of the file you'll need to be more specific as to the requirements / protocols involved. If you're writing your own protocols then it is very simple, if you're using standard protocols then it is simple also (depending on the complexity of the protocol).
Most important question, do you have control over the PDA side or is that already built-in?
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
I know about the ports namespace you have mentioned.I have the control over thePDA side as well.Because i am writing the application for that side as well.I have no idea about which protocol to use.Can you kindly send me just a simple code so that i might be able to work on it.
Thanks a lot for your reply.
Ahsan Ullah
|
|
|
|
|
Is the serial port being used for any other purpose in the application other than sending files?
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
Ahsan-AhsanS wrote: I have no idea about which protocol to use.Can you kindly send me just a simple code so that i might be able to work on it.
Regarding the protocol it doesn't really matter since you control both sides you can do what you want. It all depends on what your requirements are, e.g. if you're just sending a file then all you could potentially do is open the port, send a query string, e.g. "OK?", if the PDA returns "OK" back then simply send the entire file with a checksum at the end. If the checksum matches all well and good, if not then resend.
That would be the simplest solution (although I suggest sending it in blocks of say 0x100 bytes and checksum each of these blocks so you don't have to resend the whole file.
If the serial port is being used for other stuff as well then you'd have to make it a bit more complicatated, (e.g. replace the "OK?" with "SendFile?", if it can be sent then it responds with an Ack ("OK") and you perform the previous steps).
As for the simple code, I'm sorry I don't have time, I have my first (final) A-Level module tomorrow.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
Too few parameters. Expected 2
my sql string is this ,the error comes from the where clause
odbcComm.CommandText = "SELECT studenti.user_name,studenti.Nume, " +
"studenti.Prenume, cursuri.denumire_curs, note.nota, note.data " +
"FROM studenti INNER JOIN (cursuri INNER JOIN [note] ON " +
"cursuri.id_curs = note.id_curs) ON (studenti.id_stud = note.id_stud)"+
" WHERE studenti.user_name=@user AND note.data < @date";
when comparing the dates,
odbcComm.Parameters.Add(new OdbcParameter("@date",date.ToString()));
odbcComm.Parameters.Add(new OdbcParameter("@user", user));
this is how i declared my parameters,im using an Acces Database,
thanks and thanks for the answers before!
...
i put the space there but still get the error
-- modified at 15:44 Sunday 4th June, 2006
|
|
|
|
|
In SQL keeping the spaces is very but VERY importent!
As I see in here, you connect the end of the line before the end, to the last line, so it comes like this: "note.id_stud)WHERE "...
NOT GOOD!!! make a space, it doesn't know it has a WHERE in it.
I should suggest you to space everythine in there.
|
|
|
|
|
The error message means that you have two names in the query that doesn't exist in the database. Check the names of the table and the fields.
---
b { font-weight: normal; }
|
|
|
|
|
ODBC Syntax for queries expects parameters to be represented by '?' placeholders. Named parameters are not supported.
Change your query to
"SELECT studenti.user_name,studenti.Nume, " +<br />
"studenti.Prenume, cursuri.denumire_curs, note.nota, note.data " +<br />
"FROM studenti INNER JOIN (cursuri INNER JOIN [note] ON " +<br />
"cursuri.id_curs = note.id_curs) ON (studenti.id_stud = note.id_stud)"+<br />
" WHERE studenti.user_name= ? AND note.data < ?";<br />
then be sure to add your parameters in exactly the ORDER they appear in the query. You can use any names for the parameters (just don't duplicate names) since they are ignored.
|
|
|
|
|
HI ALL !
i want to use a special format for MaskedTextBox , For Example an arabian Date like this :"yyyy/mm/dd".because Date Format for MaskedTextBox is a "christian format ".how can i do it ?
thanks for any help !
s_mostafa_h
-- modified at 14:54 Sunday 4th June, 2006
|
|
|
|
|
If you are using VS then in the design mode, you can click once on it, and a little arrow will apear, in there, you can set the Mask.
On the window that opened you can Costum design your Mask.
Good-Luck.
|
|
|
|
|
thanks , but i want to give an error message if the user enter a wrong format (for an arabian date like :14--/--/-- or yyyy/mm/dd).
regards,
s_mostafa_h
|
|
|
|
|
Can't you use a DateTimePicker? it's alot easyer!
You either can open the Calander, or either you can choose the year, month or day like list-box, very comfterbale (bahhh don't know english), and is set to your home language.
|
|
|
|
|
At design time, in the property window, set the mask property to the mask you want to set.That's it...
Wasif Ehsan
|
|
|
|
|
Wasif Ehsan wrote: Can't you use a DateTimePicker ?
I want to use a Persian or Arabian Date . How can I change DateTimePicker Control to Persian or Arabian Date ... .
thanks a lot .
s_mostafa_h
|
|
|
|
|
What i have is a panel (in a windows form, let's call it mypanel) with no active scrollbars (autoscroll set to false). I don't need them and I don't want them to appear. In my code I use mypanel.HorizontalScroll.Value = value to scroll the panel. This code appears in the scroll event of another scrollbar in the form. This works fine, except one thing. When I move the slider of the other scrollbar mypanel of course gets repainted. But when repainting the scrollbars of mypanel are painted, too. Of course this is a temporary effect, because they disappear later in the painting cycle. So a painting cycle looks like this: Scrollbars painted, scrollbars removed, .... And this over and over cause I'm dragging a slider so the sroll event occurs many times. This leads to flickering when dragging the slider. So how can I get rid of the scrollbars in mypanel getting painted? Of course I could move the objects in mypanel manually without using the horizontal scroll, but this would be a worse solution. So any help is appreciated.
-- modified at 14:28 Sunday 4th June, 2006
|
|
|
|
|
I did this using a datagrid but the same result will apply.
Make an inherited user control that inherits the panel and simply set the width of the vertical scrollbar to 0 (and the height of the horizontal scrollbar).
This should give you the hidden scrollbar effect that you want.
|
|
|
|
|
.......
"WHERE studenti.user_name= '"+user+"' AND note.data < '"+date+"'";
the error comes from comparing the note.data which is also a date in a table built in MS Access,
this is the definition for date : DateTime date = DateTime.Now;
i must convert date.To"Something" or something like that but i dont know to what to dont get this error
is posible or must i do it somehow else?
Thanks
-- modified at 12:44 Sunday 4th June, 2006
|
|
|
|
|
Consider using parameterized queries. This would avoid type conversion errors like this, and is better practice since it avoids vulerability to SQL Injection Attacks.[^]
|
|
|
|
|
Access uses the # character around dates, not apostrophes.
Use parameterized queries, as Rob suggested, it will put the proper characters around the value regardless of what database you are using.
---
b { font-weight: normal; }
|
|
|
|
|
Does anyone know how to change the location of a button using programming. I'm going to use it to make "simple" and "advanced" options in my search program.
Thanks
Hengy
I like Pie
|
|
|
|
|
Please don't double post, your old thread is perfectly suited for this question.
Anyway, here is the solution:
Button b = new Button();
b.Location = new Point(10, 10);
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Sorry for the double post...
I have another problem:
when the doesn'tpick anything from a combobox, it says:
System.NullReferenceException was unhandled
but in my code, I put a default setting in my switch.
private void button1_Click(object sender, EventArgs e)
{
if (checkBox1.Checked != true)
{
MessageBox.Show("Search");
}
else
{
switch (comboBox1.SelectedItem.ToString())
{
case ("Mininova"):
string targetURL = @"http://www.mininova.org";
System.Diagnostics.Process.Start(targetURL);
break;
case ("TorrentSpy"):
string targetURL2 = @"http://www.torrentspy.com";
System.Diagnostics.Process.Start(targetURL2);
break;
case ("IsoHunt"):
string targetURL3 = @"http://www.isohunt.com";
System.Diagnostics.Process.Start(targetURL3);
break;
case ("MyBitTorrent"):
string targetURL4 = @"http://www.mybittorrent.com";
System.Diagnostics.Process.Start(targetURL4);
break;
default:
MessageBox.Show("Please select a website to search.");
break;
}
}
}
any ideas?
thanks for the help... I seem to be asking alot of it today!
Hengy
I like Pie
|
|
|
|