|
Hmmm, just did a search on facebook api and 5 articles did pop up. The simple WPF facebook application one looks kind of interesting.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
here's my sample program in my addProducts..
if i click my save button.. when i run it, i prompts an error message that reader is closed.. can anyone help me?
private void btnSaveChangesObject_Click(object sender, EventArgs e)
{
try
{
clsPublic.objConn.Open();
OdbcCommand com = new OdbcCommand("Select Name from Products", clsPublic.objConn);
OdbcDataReader read;
read = com.ExecuteReader();
while (read.Read())
{
if (read[0].ToString() == txtprodname.Text)
{
MessageBox.Show("Error!");
}
else
try
{
String strSQL;
if (clsPublic.BoolUpdateProductsRec == true)
{
strSQL = "Update products Set Id = '" + txtprodId.Text +
"', Name = '" + txtprodname.Text +
"', Description = '" + txtdesc.Text +
"', Type = '" + txttype.Text +
"', Price = '" + txtprice.Text +
"', Brand = '" + txtbrand.Text +
"' where Id = '" + txtprodId.Text + "'";
}
else
{
strSQL = "Insert Into products Values('" + txtprodId.Text +
"', '" + txtprodname.Text +
"', '" + txtdesc.Text +
"', '" + txttype.Text +
"', '" + txtprice.Text +
"', '" + txtbrand.Text + "')";
}
SaveObjectRecord(strSQL);
btnCloseSaveChangesObject.PerformClick();
}
catch (NullReferenceException NRE)
{
MessageBox.Show("Error:" + NRE.Message, "ARTM", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
catch (NullReferenceException NRE)
{
MessageBox.Show("Error:" + NRE.Message, "ARTM", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
|
|
|
|
|
Looks messy. When do you get the error ? Which catch block is it in ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: Looks messy.
Yes, it does. Not to mention the sql injection attack vulnerability
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I've given up on pointing that out. People who hire teams who have no idea how to write secure code, deserve what they get.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: given up on pointing that out
Same here. Used to point people towards Colin's article and some were grateful and others, well, they didn't really care ( at least until someone tosses a
'; drop database master; -- or some crap like that into the query string ).
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I suppose that the SaveObjectRecord method closes the connection? Then you will get the error after saving a record when you try to continue to read the rest of the records.
Do you really indend to update/insert the same record over and over again, once for each record in the Products table? Or did you accidentally put the code that saves the record inside the loop instead of after the loop?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
Hi guys,
I'm starting out with C# and since I dont like messing with simple things ( ) I'm already "playing" with threads and delegates. In my program I create a net socket, connect to a server and start to receive data async with BeginReceive.
When a message is received, the program(secondary thread of BeginReceive) pass it to RlsInsert(message) that split it with a regular expression and populate a listview. It seems to work perfectly but randomly VS pops up with an exception about NullReferenceException and tells me to use the "new" keyword, but as you can see I'm already using it:
//Add item to the list view
public delegate void RlsInsertCallback(string text);
public void RlsInsert(string text)
{
if (this.InvokeRequired)
this.Invoke(new RlsInsertCallback(this.RlsInsert),new object[] { text }); <--- expection on this line pointin to object[]
else
{
**more code that check text with regular expression, split text and populate subitems etc
lvRelease.Items.Add(aItem);
}
}
Can anybody tell me what I am doing wrong? Because I cant figure it out. It works and then It crashes after a while.
Sorry if this has already been asked, I did used search but I could not find anything that really match my problem.
Thank you in advance.
Matteo
|
|
|
|
|
Could this.RisInsert or text be null ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks for replying.
I changed the code a bit includin a check for null text:
public void RlsInsert(string text)
{
if (text != null)
{
if (this.InvokeRequired)
this.Invoke(new RlsInsertCallback(ListAddItem), new object[] { text });
else
{
ListAddItem(text);
}
}
}
But I get the same error. Not sure about this.RlsInsert (ListAddItem: I put the code to populate the listview in another method) null or not. How can it be null?
|
|
|
|
|
I would do a try/catch and then check the values of the various variables when the catch occurs.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Ok I'm doing it right now, I'll let you know. Ty
|
|
|
|
|
I have 5 items in a listbox and am custom paiting each item. but if i click at the very bottom within the listbox i should be getting -1 but I always get the last item index.
private void listbox_MouseDown(object sender, MouseEventArgs e)
{
int indx = this.IndexFromPoint(e.X, e.Y);
MessageBox.Show(indx.ToString());-->>; I always get the last item index
}
I ran a simple test by adding a listbox on a form and on a mouse click if i click outside of the listitem i get -1. means no item is selcted.
Can somebody tell me where the problem os
|
|
|
|
|
What if you handle mouse up instead of down ? Perhaps the selection changes in mouse click, which fires between down and up.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hello All,
I am wondering if it is possible to get the drop location in explorer after you drag and then drop to explorer.
I would like to generate some files at the drop location, not copy\move existing files on the computer.
Thanks
|
|
|
|
|
Using VS2008 in Vista - I'm trying to make use of this code:
http://www.codeproject.com/KB/combobox/ComboBox_appears_flat.aspx[^]
In the designer, the control paints as expected. However, when the application is actually run, the control has an inner white border (including one that separates the down-arrow button with the control's text area). Is there something available (another flat combobox class) that is more reliable?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
The .Net ComboBox control does not support flatness.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Is there any way to get an Excel 2003 xml file to show images?
I understand they can't be included in the document, but is there a way to reference images by URL and have them shown when it is opened?
Thanks
-c
|
|
|
|
|
GibbleCH wrote: Excel 2003 xml file
Excel 2003 doesn't support XML as a workbook format. I don't get what you're really trying to do.
|
|
|
|
|
|
Hmm...I had no idea.
Well, depending on how you're doing this, it may or may not be supported. If you are trying to embed the image data directly into the XML, it's not supported. If you are using an external file to store the image, then you might get away with it. This[^] is the best discussion I could find on the subject.
|
|
|
|
|
I had found that, unfortunately it's using the new SpreadsheetML format in use by Excel 2007, not Excel 2003
|
|
|
|
|
Yeah, I was kind of shocked at what that file really is. Have you tried renaming that file to whatever.ext.zip?? Pretty interesting what you find inside.
|
|
|
|