|
Thank you very much, this helps with the date. I tried to use this with the phone number but it did not work. Can you tell me how to format the phone textbox and load in the phone number, I hope. Thanks again.
Norm
|
|
|
|
|
Yes, you could say something like:
phone.ToString("(###) ### - ####");
Hope this helps.
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Thanks again for you help. Your suggection did not work, I am including some code to give you an idea of what I am trying to do. I am trying to insert a record into a SQL table, it works now I am trying to format the phone numbers. All I get is the format. I hope this helps.
//
// sqlInsertCommand1
//
int rsIdentity;
String format = "(###) ###-####";
SqlCommand cmdGetIdentity = new SqlCommand();
System.Text.StringBuilder b;
try
{
b = new System.Text.StringBuilder(" ");
txtNpets.Text = Convert.ToString(0);
txtHphone.Text = format.ToString();
b.Append("INSERT INTO [owner-info] (salutation, [owner-fname], [owner-lanme], [owner-address] , [owner-city], [owner-state], [owner-zipcode], [owner-home-phone], [owner-work-phone] , [owner-cell-phone], [owner-emgr-phone], [owner-emgr-contact], [owner-email] , [owner-fax-number], [owner-refered-by], pets) values('");
b.Append(txtSal.Text);
b.Append("','");
b.Append(txtFname.Text);
b.Append("','");
b.Append(txtLname.Text);
b.Append("','");
b.Append(txtAddress.Text);
b.Append("','");
b.Append(txtCity.Text);
b.Append("','");
b.Append(txtState.Text);
b.Append("','");
b.Append(txtZcode.Text);
b.Append("','");
b.Append(txtHphone.Text);
b.Append("','");
b.Append(txtWphone.Text);
b.Append("','");
b.Append(txtCphone.Text);
b.Append("','");
b.Append(txtEphone.Text);
b.Append("','");
b.Append(txtEcontact.Text);
b.Append("','");
b.Append(txtEmail.Text);
b.Append("','");
b.Append(txtFphone.Text);
b.Append("','");
b.Append(txtRefered.Text);
b.Append("','");
b.Append(txtNpets.Text);
b.Append("') SELECT @@IDENTITY ");
sqlInsertCommand1.CommandText=b.ToString();
this.sqlConnection1.Open();
sqlInsertCommand1.ExecuteNonQuery();
|
|
|
|
|
Here's a simple example of what I meant before:
string <code>s</code> = "0387465363";
this.textBox1.Text = s;
this.textBox1.Text = String.Format("{0: (##)-###-####}", Convert.ToInt32(s));
Try it this way.
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Thanks again it works! I had to change ToInt32 to Int64.
|
|
|
|
|
You are welcome. Glad I could help
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
I need to ask another qustion? I need to convert the same type of textbox data
to money. I think I can use the same concept you gave me but what would the
the format look like? I tried this: "String.Format("${(0).}", Convert.ToInt32(s))". There is a format error at runtime.
Norm
|
|
|
|
|
Have a look here[^] for all your string formatting questions Norm. I think this will solve your problems.
Hope this helps.
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
HI
this is a.xml file i want to display the value of username to label in winform
<resource>
<item name="username">san
<item name="password">Password
<item name="login">Login
<item name="rememberMe">Remember Me?
<item name="usernameRequired">Username required
<item name="passwordRequired">Password required
<item name="invalidLoginInformation">Your username/password could not be found
waiting for th eprompt reply
|
|
|
|
|
In Photoshop CS there is such functionality:
Image>Adjustments>Threshold
I do need to implement such functionality in my c# application, but I don't know how!? Does any of you know where I can find such implementation?
Thanks in advance
|
|
|
|
|
you can try this www.mathtools.net you may find various image processing algorithms written either in c++ or matlab... Alternatively, GOOGLE. Or go read the book from John C Russ, you may find a pseudo algorithm in his book.
edit: you can try the mathworks website and go to the user decidated code section and browse through the image processing section. There is a tonne of image processing code written in matlab.
|
|
|
|
|
Try this peace of code .. instead of giving an error it connects to a ipHostEntry that doesn't exist
Can anyone tell me why ?
Why me ? Oh .. why ?
using System;
using System.Net;
using System.Net.Sockets;
namespace ThisIsStupid
{
public class MainC
{
public static void Main()
{
IPEndPoint ipe = new IPEndPoint( IPAddress.Parse( "193.168.0.6"),21);
//System.Diagnostics.Debug.WriteLine( ipadd );
Socket s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
// Console.WriteLine(s.Connected );
s.Connect(ipe );
if( s.Connected )
{
Console.WriteLine( " I have a socket that didn't connect to nothing ");
Console.WriteLine(" But it's status is connected ");
Console.WriteLine(" Uraaa !");
}
}
}
}
I've made a client - server aplication and my class informes the main program that the requiered connection exists when no client is available there .. ? Why ... is that correct ... what am I doing rong ?
Lazar Mihai
Highschool student
|
|
|
|
|
|
NO .. I tried with port 7891 and with 4545 .. if you have any other suggestions ... try on you computer you'll get the same result
Lazar Mihai
Highschool student
|
|
|
|
|
I extended your class so I could see what was happening. When I tried the other ports you mentioned I got an exception to say that it wasn't connected. When I tried port 21 my application returned:
32 32 30 20 4d 69 63 72 : 220 Micr
6f 73 6f 66 74 20 46 54 : osof t FT
50 20 53 65 72 76 69 63 : P Se rvic
65 d a 0 0 0 0 0 : e
public class MainC
{
private static byte[] buffer = new byte[1024];
public static void Main()
{
IPEndPoint ipe = new IPEndPoint( IPAddress.Parse( "127.0.0.1"),21);
Socket s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
s.Connect(ipe );
if( s.Connected )
{
Console.WriteLine( " I have a socket that didn't connect to nothing ");
Console.WriteLine(" But it's status is connected ");
Console.WriteLine(" Uraaa !");
}
else
{
Console.WriteLine("Not Connected");
}
int result = s.Receive(buffer, 1024, SocketFlags.Peek);
Console.WriteLine("Received {0} bytes", result);
for(int i=0; i<result; i+=8)
{
Console.WriteLine("{0:x} {1:x} {2:x} {3:x} {4:x} {5:x} {6:x} {7:x} : {8}{9}{10}{11} {12}{13}{14}{15}",
buffer[i], buffer[i+1], buffer[i+2], buffer[i+3],
buffer[i+4], buffer[i+5], buffer[i+6], buffer[i+7],
(char)buffer[i], (char)buffer[i+1], (char)buffer[i+2], (char)buffer[i+3],
(char)buffer[i+4], (char)buffer[i+5], (char)buffer[i+6], (char)buffer[i+7]
);
}
Console.ReadLine();
}
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Don't connect to local host ... on local hosts it works ...
I want on other ip addresses not to work ...
Lazar Mihai
Highschool student
|
|
|
|
|
|
You are right .. thanks I think I 've fixed the bug
Lazar Mihai
Highschool student
|
|
|
|
|
|
Cool ... telnet worked .. why if the address doesn't exist on the LAN .. ?
Lazar Mihai
Highschool student
|
|
|
|
|
Hi I am converting a wmf(drawing file) file in to hexa decimal Format here I am able to convert the data from WMF file to hexadecimal but the problem is the characters
(A,B,C,D,E,F)in converted Hexa decimal format are coming in Small Case letters which should be in capital Letters can any of u help in getting the characters in to Capitals
I am using the following code to convert.
uint uiDecimal = 0;
uiDecimal=checked((uint)System.Convert.ToUInt32(shapeDiagramData[i]));
string str;
str = String.Format("{0:x2}",uiDecimal);
sw.Write("{0}", str);
Shashidhar.
|
|
|
|
|
|
I am getting errors when I try to insert data into my database. I dont have any problems viewing the database. I think it is a problem with my insert statement:
oleDbInsertCommand1.CommandText="INSERT INTO UserTable(Username,Password) VALUES('@NewUserTextBox.Text','@NewPasswordTextBox.Text')";
oleDbInsertCommand1.ExecuteNonQuery();
I have even tried it without the @ and other ways. This is the error I get below.
System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
|
|
|
|
|
You can do it this way, but it's susceptible to SQL injection attacks (a common way that malicious users can attack a web site and destroy databases):
oleDbInsertCommand1.CommandText="INSERT INTO UserTable(Username,Password) VALUES('" + NewUserTextBox.Text + "','" + NewPasswordTextBox.Text + "')";
Instead you should set up an oleDbParameter collection and attach it to the oleDBInsertCommand1 object. You'd populate the paramters from the two textboxes (NewUserTextBox and NewPasswordTextBox). If you named these parameters '@NewUser' and '@NewPassword' respectively, then you'd code the CommandText as follows (notice that there are no single quotes here):
oleDbInsertCommand1.CommandText="INSERT INTO UserTable(Username,Password) VALUES(@NewUser, @NewPassword)";
This is the secure, recommended best-practice solution. There is more help on parameter collections in the Visual Studio on-line help.
|
|
|
|
|
I need to know how to re-draw graphics on my forms when the forms are minimized or lose focus. I know there are an Update() and Invalidate() method but when I use them they don't work. I need to know where to put them actually.
I already know that the OnPaint() method is called when the form loses focus and graphics need to be drawn. The reason i don't want to go that route is because I am using a button control that when pressed, there are counters that will change the coordinates of the graphic shape. This means I would have to save the current state or coordinates after each time the button is pressed and it would be a hassle to pass all of this to the OnPaint() method, even though it could be done.
I just need a simple way to redraw my graphics in the forms.
|
|
|
|
|