|
student1988 wrote: well I tried to assign a DateTime object to Value but it didnt work either
Define "didn't work". Exactly how did it not work? Did it cause an exception? Did it fail to compile? Did it run but the result was wrong? What?
Man who stand on hill with mouth open wait long time for roast duck to drop in
|
|
|
|
|
it threw the same format exception again.
|
|
|
|
|
now define 'it'
exceptions hold a lot of information, including exact line numbers. Which statement throws what?
the quality and detail of your question reflects on the effectiveness of the help you are likely to get
|
|
|
|
|
During runtime when I execute shiftInsertNewRow() method I get a Format exception at this line:
command.ExecuteNonQuery() that says input string was not in a correct format.
|
|
|
|
|
I am not sure, haven't used command parameters like that yet, however I expect the "Values" you provide should come as a string representation that converts automatically to the type you specified, hence:
1. the DateTime parsing will succeed only when the string was formatted according to your default DateTime format, which is a user's preference (see regional settings).
2. an empty textbox will not convert to most simple types; example: int.Parse("") throws an exception!
3. there is an issue about null; when null is intended, it must be specified as DbNull.Value
|
|
|
|
|
i try make a litle chat that will be server/client
but i have a major issu , when everithing is working local it seem i'm not able pass my gateway if i not forward manualy the required port.
now i have tryed the upnp and i think the code work but my netbox refuse the upnp protocole >>
so i feel not using upnp since not everyone able use it or they will have to enable it + i heard of lot of security issue.
now i searched an other way to do it and found nothing on net.
but i see msn is enable forward port in my non upnp box?? or even other app like azureus bit torrent accept in/out conection (they not forward the port in my netbox though).
so my question is how those programme able to do that on a non upnp gateway???
how can i do the same thing all i need is to echange 2 ligne of chat realy that can't be that hard ><.
(no need talk about why i do a server/client for each user that not the point, the point is how to deal with port).
chunk of code apreciate^^
|
|
|
|
|
Maybe with holepunching, you might want to look that up.
You're right though, NAT is a major issue. And it doesn't look like it's going away soon (maybe with IPv6 - which isn't going to be actually here soon)
|
|
|
|
|
I won't wait on something that may come out solution already exist since some app are able corectly setting my gateway just they not well documented.
|
|
|
|
|
I don't really understand you, and I'm afraid I don't speak French..
What do you mean, exactly?
|
|
|
|
|
trying to be more clear.
My friend send me "hello" in chat on my IP 83.231...... port : 666
now i need forward this port so the message "hello" is redirected on my PC where the chat is instaled
so i need forward port :666 send incoming soket to 127.0.0.1
one way to do it is manualy through gateway administration .
second is Upnp.(wich wont work on half computer).
third is what i search how msn/azureus/etc... do it on a non-upnp gateway.
|
|
|
|
|
Maybe they don't. MSN sure doesn't need it, all messages go through MS-servers (so beware..)
Azureus could do without, speeds will suffer but oh well.. But in any case, I don't know how they it would even be possible to forward a TCP port without UPnP. For UDP ports you could use hole-punching.
|
|
|
|
|
When i open msn it does config a port on my router i cheked it through admin
it open an udp port maybe my box is preset to only allow msn do that.
i'm prety sure my box has a upnp function just its maybe restricted to famous programme.
so what is the principe of hole-punching TCP does it allow a server listen to this port and receive soket? is it how emule/azureus does work?.
|
|
|
|
|
A router that would allow TCP hole-punching would be "broken".
UPnP is "difficult", there are far too many different implementations in routers, some of them really generous and allowing even the most the malformed request to open a port, others nitpicking about the number of spaces and refusing to even tell what went wrong.
Ok so MSN does open a port? It still shouldn't need it but ok.. could you see whether it was UPnP-forwarded or opened as the result of outgoing packets?
The router can not know that it was MSN though, so whatever it did, you can do the same. I recommend you use WireShark/Ethereal to capture how it opens the port (and look at Azureus as well, of course)
|
|
|
|
|
Hello Forum.
I am building an application where menu to call the forms are table driven,
I can call the forms by using reflection as follows, however I need to verify first if this form is not open yet, and if it is just set the focus on this form.
My question is, how can I find out if the form is already open?
Thank you very much for your help
Assembly myAssembly = Assembly.GetExecutingAssembly();
Form myForm = myAssembly.CreateInstance(this.GetType().Namespace+".Form2") as Form;
myForm.Show();
|
|
|
|
|
I have a simple application timer program - allows any executable to launched, with command line arguments (optional) and terminates after specified number of minutes.
Here's how I'm currently terminating timed process:
while (true)
{
if (dtEndTime <= DateTime.Now || p.HasExited)
{
if (!p.HasExited)
p.Kill();
break;
}
System.Threading.Thread.Sleep(500);
}
Rather straight forward and works most of the time. A crash occurs when I am timing a program called Fraps.exe and its minimized to the tray. The crash itself doesn't always have the same results.
What is consistant is:
- the app Kill() is called for IS closed
- a crash occurs
What varies:
- another app in the tray will crash as well (intermittently)
If I do not minimize Fraps.exe to the tray no crash occurs (however, leaving it on the desktop is not an acceptable solution). Fraps can be closed via task manager without issue.
Any suggestions on how to terminate an external application more gracefully? Process.Close() and Process.CloseMainWindow() have already be ruled out for the case of being in the tray. I'm open to anything will work and not cause a crash.
---------------------------------------------
Help... I'm embedded and I can't get out!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler
|
|
|
|
|
I made a T9 dictionary please take look I'am waiting your opinions.
Here is the code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace T9Sozluk
{
public partial class frmT9 : Form
{
public frmT9()
{
InitializeComponent();
}
SqlConnection Baglanti = new SqlConnection(Properties.Settings.Default.DBYolu.ToString());
SqlCommand Komut;
SqlDataReader dr;
string text = "", sonuc = "";
string[] dizi = new string[1];
int sayi = 0, deger=0, Lstart = 0, Lend = 0;
Point pnt;
bool swich = true;
bool show = true;
private void Form1_Load(object sender, EventArgs e)
{
Baglan(true);
listBox1.Hide();
}
public void Baglan(bool value)
{
if (value)
{
if (Baglanti.State == ConnectionState.Closed)
Baglanti.Open();
}
else if (!value)
{
if (Baglanti.State == ConnectionState.Open)
Baglanti.Close();
}
}
private void MakeSelection()
{
richTextBox1.SelectionStart = richTextBox1.TextLength;
richTextBox1.SelectedText = Convert.ToString(listBox1.SelectedItem);
sonuc = richTextBox1.Text;
sonuc = sonuc.Remove((Lend - sayi), sayi);
richTextBox1.Text = sonuc;
Lstart = richTextBox1.TextLength;
swich = true;
listBox1.Hide();
}
private void ShowSelection()
{
if (!show)
{
listBox1.Items.Clear();
Lend = richTextBox1.TextLength;
sayi = Lend - Lstart;
text = richTextBox1.Text;
if (Lstart > 3)
text = text.Remove(0,Lend-sayi);
text = text.TrimStart(Convert.ToChar(" "));
sayi = text.Length;
text = text + "%";
Komut = new SqlCommand("select count(kelimeadi) from kelimeler where " +
"kelimeadi like @KelimeAdi", Baglanti);
Komut.Parameters.Add("@KelimeAdi", SqlDbType.NVarChar).Value = text.ToString();
try
{
dr = Komut.ExecuteReader(CommandBehavior.SingleResult);
if (dr.Read())
deger = dr.GetInt32(0);
}
catch (Exception hata)
{
MessageBox.Show(hata.ToString());
}
dr.Close();
dr.Dispose();
if (deger>0)
{
Komut = new SqlCommand("Select Kelimeadi From Kelimeler Where" +
" KelimeAdi like @KelimeAdi", Baglanti);
Komut.Parameters.Add("@KelimeAdi", SqlDbType.NVarChar).Value = text;
dr = Komut.ExecuteReader();
if (dr.Read())
{
for (int i = 0; i < deger; i++)
{
dizi[0] = dr.GetString(0);
listBox1.Items.Add(dizi[0]);
dr.Read();
}
}
dr.Close();
dr.Dispose();
}
if (deger>0)
{
pnt = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength);
pnt.X = pnt.X + 15;
pnt.Y = pnt.Y + 20;
listBox1.Location = pnt;
listBox1.Show();
}
}
}
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar == 17))
{
show = false;
swich = false;
}
else
show = true;
if (!swich)
{
if (e.KeyChar == 13)
MakeSelection();
else
ShowSelection();
}
}
private void tsItemEkle_Click(object sender, EventArgs e)
{
Komut = new SqlCommand("Insert into Kelimeler(KelimeAdi) values(@KelimeAdi)", Baglanti);
Komut.Parameters.Add("@KelimeAdi", SqlDbType.NVarChar).Value = text.Remove(sayi);
try
{
Komut.ExecuteNonQuery();
MessageBox.Show("Kelime Listeye Eklendi...");
}
catch (Exception hata)
{
MessageBox.Show(Convert.ToString(hata));
}
return;
}
}
}
modified on Wednesday, May 6, 2009 4:46 PM
|
|
|
|
|
Use <pre></pre> tags around your code. (Use the code block widget below the reply area rather than type them if you prefer.)
Then format the code, you know indenting and so on, to make it readable, and you might get some answers. Probably not though.
If you like the code you have written then make an article around it and submit it in the normal way.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thank you for advice it looks better now.
|
|
|
|
|
emrah1982 wrote: I'am waiting your opinions.
A man's got to believe in something. I believe I'll have another beer!
|
|
|
|
|
Hi,
Is there any way to get the following to work?
bool s = _myProperty == true ? Method1() : Method2();
Or is this just silly talk?
|
|
|
|
|
Yes so long as the return types of Method1/2 are bool also.
|
|
|
|
|
I believe they (method1/2) would also have to be static (?)
---------------------------------------------
Help... I'm embedded and I can't get out!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler
|
|
|
|
|
Only unless the method that is using this code is also static... otherwise they dont need to be. From the looks he is testing an internal variable so chances are it wont be static.
Edit: But it could be static even if it wasnt static... could go either way.
|
|
|
|
|
Jammer wrote: bool s = _myProperty == true ? Method1() : Method2();
Why doesn't it work? It should, as long as Method1() and Method2() return bool, or return types convertible to each other and to bool.
|
|
|
|
|
S. Senthil Kumar wrote: or return types convertible to each other and to bool
Good lord, I still remember that post on your blog. I asked a few people, and nobody knew it! I wonder why they made that restriction.
Cheers,
Vikram. Current activities:
Films: Sense and Sensibility
TV series: Friends, season 2
Books: Longitude, by Dava Sobel. Carpe Diem.
|
|
|
|