|
|
hi I did the same thing which u suggested in that link but i am getting this exception
An unhandled exception of type 'System.Data.DBConcurrencyException' occurred in system.data.dll
Additional information: Concurrency violation: the UpdateCommand affected 0 records.
my code is like this
The table is tblPatientMaster with feilds one PatPhoto thats is long Blob and one patientId that is a bigint.
public static void UpdatePatientPhoto( long PatID,ref byte[] content )
{
DataRow PatRow;
String ConnectionString =
System.Configuration.ConfigurationSettings.AppSettings["DSN"];
String query= "Select* from tblpatientmaster where patientId = " +
PatID ;
OdbcConnection myConnection = new OdbcConnection(ConnectionString);
myConnection.Open();
OdbcDataAdapter myAdapter=new OdbcDataAdapter(query,myConnection);
DataSet ds= new DataSet("tblpatientmaster");
myAdapter.UpdateCommand = new OdbcCommand
("UPDATE tblpatientmaster SET " +
"PatPhoto = @iPHOTO " +
"WHERE patientId = @iPatNo", myConnection);
myAdapter.UpdateCommand.Parameters.Add("@iPHOTO", OdbcType.Binary,
content.Length, "patphoto");
myAdapter.UpdateCommand.Parameters.Add("@iPatNo", OdbcType.BigInt,
0, "patientId");
myAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
myAdapter.FillSchema(ds, SchemaType.Source, "tblpatientmaster");
myAdapter.Fill(ds,"tblpatientmaster");
DataTable PatTable = ds.Tables["tblpatientmaster"];
PatRow = PatTable.Rows.Find(PatID);
PatRow.BeginEdit();
if (content.Length != 0)
{
PatRow["PatPhoto"] = content;
}
PatRow.EndEdit();
myAdapter.Update(ds,"tblpatientmaster");
}
Pls anybody can help me with this problem.
Thanks
Monica
|
|
|
|
|
Relatively new to Web Apps (I've used them before, but was just reusing code, not creating). What I need is to display data read from a database in the following manner:
Header Header2 Header3
Item1 Item4 Item7
Item2 Item5 Item8
Item3 Item6
So basically 8 items will be read from a database, and it will group the items based on the common Header property. When it has displayed 3 I want it to go to the next line. Any advice?
|
|
|
|
|
Yeah, a repeater will give you the control you need here. Although, if it were me, I'd make things easier by writing a stored procedure that created three columns so that the presentation tier didn't need to worry about anything but displaying it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I just realize it too out the spacing I put in, so it may be a bit deceiving. What I am getting is 8 items from a DB with a Category attribute. So say the result would be something like:
Name1 | Category1
Name2 | Category1
Name3 | Category2
Name4 | Category3
Name5 | Category3
And so on. Can I still do this with the repeater?
|
|
|
|
|
Oh, I see. You can still do it with a repeater, you could do it by creating three tables, one for each category, and then binding the dataset to the repeater and accessing the three tables in the data items for the three rows.
I still lean towards a stored procedure that returns one table with three rows, based on category. Then the presentation layer is easy, as it should be.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am writing a tool in .Net to display all group policy available in a domain and all application added to each policy. I am able to display all policy available in the domain but I cannot display the application assigned in the domain through the policy.
Can you please help me to display software names and other properties using vb.net or c#.net
Thanks,
Ram
|
|
|
|
|
How do you start another application from a C# program
|
|
|
|
|
Process.Start, from memory.
Yep[^], that's the one.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I want my Internet cafe solution has a firewall embedded within, how can I do that? is there any dll that I can use?
Thank you
|
|
|
|
|
it's doubtful there will be a DLL to do everything you need. If you want a real firewall you will need to do some driver level programming. I would suggest you start smaller.
-- Rocky Dean Pulley
|
|
|
|
|
A while ago I had asked for the proper approach to manage image mapping to dynamically created controls. The way that I have approached it thus far is to have some image files linked to the controls rather than adding them as a binary resource file into the control at loading time. Because I need to be able to overwrite the files on occasion, I still must keep the original image files like .jpeg or .gif files. What I would like to know is, is it possible to import those image files into the Image.FromStream() method into the Image file as a binary file programmatically rather than linking to the file? Load the image files into the controls in the onLoad event as binary files rather than linking to the external image files thereby removing that constraint on the application, but whenever new files are needed then the new image files could be loaded the same way.
Stated another way. First, what is the proper procedure for importing an image as a resource into an image-bearing control like a PictureBox control, and second, is it possible to use those image files as a resource programmatically? To be able to import the binary file into the control programmatically when the application starts would solve several problems including control invalidation and redrawing. Would really appreciate some insight.
|
|
|
|
|
I don't understand. If the jpg/gif files exist on disc, why do you need to use FromStream instead of FromFile ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Image.FromFile() locks down the image file handle so that it cannot be overwritten, whereas Image.FromStream() does not lock the file down. The question under these circumstances is, can I read the image file in binary form as a resource programmatically so that it stores the image file in binary format in the application as a resource as opposed to as a file handle? Also, could I read in other files in the same way dynamically (programmatically) so that it would simply overwrite the previously stored binary file as a resource?
|
|
|
|
|
I have a dialog box to send email. Initially, I set the AcceptButton/CancelButton properties, but they are not set anymore. Instead, I set DialogResult myself, and in the click handler for the OK button I do something like this
if (check if emailaddress is not valid )
{
MessageBox.Show("blah blah");
}
else if (check something else)
//etc
else
{
// send the email
this.Close();
}
No matter what happens, the dialog closes when this handler is called.
I created a second dialog to configure the server details, etc. Same setup, used my own handler for clicking OK and Cancel. If you click the OK button, similar code works fine without closing the dialog. If you click cancel, the dialog closes, and so does the dialog that spawned it.
Does anyone know what's going on here ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
eh. Did you debug/F11 every line? Obvious cause would be that this.Close() is called MSDN says that "Although setting the DialogResult property will cause your dialog box to close automatically, you can still handle the control's Click event, and the dialog box will close once the event handler's code is finished. While handling the Click event, you may want to halt the closure of the dialog box." (MSDN[^])
Are you sure that you aren't missing something obvious? (like code to stop closing in your second dialog? - see link)
David
|
|
|
|
|
dnh wrote:
Did you debug/F11 every line?
Fair question.
Of course. this.Close is NOT called at all. That's why I changed my if block ( before I just had return after the message box ). In fact, if I click Cancel in the second dialog, and then put breakpoints in the parent dialog, neither click handler is called ( OK or Cancel buttons ), but the dialog closes. DialogResult is set to Cancel, so I 'fixed' it for now ( had to send to the client ) by using a bool and stopping the close behaviour if Cancel has not been clicked. Stepping through the OK code in the main dialog, same thing. The message box code runs, then next code I can step to is the code in the main form that created the dialog, unless I create an OnClosing handler in there as well. I have no idea why they are closing, but it's not from my code.
dnh wrote:
Although setting the DialogResult property will cause your dialog box to close automatically, you can still handle the control's Click event, and the dialog box will close once the event handler's code is finished. While handling the Click event, you may want to halt the closure of the dialog box."
Yes, I killed all my automatic closing of dialog boxes as a first step. I've quintuple checked, and they are all set to 'none'.
dnh wrote:
Are you sure that you aren't missing something obvious? (like code to stop closing in your second dialog? - see link)
I didn't see any code in that link that seemed to help, perhaps I missed something, but my buttons are definately not set to automatically close the dialog, and certainly the problem with the second dialog is not calling either button event handler at all. If all else fails, I may have to keep the ugly bool solution and impliment something similar in the main dialog. Yuck - that's got to be a hack. I'd far rather learn what weird configuration issue is causing this. The second dialog has a similar message box setup, and it works fine there, but I can't see anything different in how the dialogs are set up.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
I have no idea why they are closing, but it's not from my code.
Me too. Sounds bit crazy. I am sure that you'll be like d'oh when you or somebody figure it out and I'll be like d'oh when you post solution here.
Have fun, I am gone, to get some sleep.
David
|
|
|
|
|
Christian, if I answer your question, do I get to steal your MS MVP status?
On a serious note, have you tried commenting out all code in your handler? I can often isolate problems by commenting out all code, then bits, then finding the actual problem. Sounds like a weird one though, good luck.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Conversation With a Muslim
Judah Himango
|
|
|
|
|
Judah Himango wrote:
Christian, if I answer your question, do I get to steal your MS MVP status?
Hey, if you answer enough, you may get your own MVP status
Judah Himango wrote:
have you tried commenting out all code in your handler?
It looks like this :
if (this is true
{
MessageBox.Show("blah blah");
}
else
{
// none of this code is called, I've stepped through to see this is the case.
}
I changed it to this to ensure the other code is never called, and I've stepped through to see for myself.
Judah Himango wrote:
Sounds like a weird one though, good luck.
Thanks - it makes no sense to me at all. I understand how to assign a button to close a dialog, and I've simply not done so. All I can think is that I did set that up early on, and some remnant of that fact is lurking beyond my reach ( in that the properties tell me it's not set ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Judah Himango wrote:
On a serious note, have you tried commenting out all code in your handler? I can often isolate problems by commenting out all code, then bits, then finding the actual problem.
That's usual method of mine.
David
|
|
|
|
|
Have you manually checked the designer-generated code? I had a case last week in vb.net where the handler got wired up wrong. I couldn't figure it out because when I used the VS editor interface, it took me to the routine I was expecting, but in the designer code, it was also wired up to another handler. As soon as I fixed that, the code I was expecting was getting called.
|
|
|
|
|
Good call - I'll give it a look tonight. I was going to just delete all the buttons and create new ones, and see if that helps.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Please see documentation for Button.DialogResult property in MSDN. It is mentioned that:
If the value of this property is set to anything other than DialogResult.None, and if the parent form was displayed through the ShowDialog method, clicking the button closes the parent form without your having to hook up any events. The form's DialogResult property is then set to the DialogResult of the button when the button is clicked.
Therefore, it is clear that for the button labeled “OK” in your dialog box, while the Text property could be set to “OK” string, but if the “DialogResult” property of this button is also set to “OK”, then clicking this button will automatically close the parent dialog box without your having to hook up any events.
So, the solution to your problem is that you must NOT set the DialogResult property of the OK button (say btnOK) to “OK”, while the Text property of this button might still continue to be “OK” to keep it visible as such to the user. You may set the DialogResult property of this button to “None”. Now, in the click handler of the said OK button, you can do your processing as desired. But please remember to close the form yourself in the code as per your scheme.
I may also mention that as per the documentation, the AcceptButton/CancelButton properties are irrelevant for this purpose because they are useful to allow "Enter" or "Escape" keys instead of the mouse-clicks on OK and Cancel buttons respectively. What is of relevance here is that DialogResult property which can have a possible of 8 values (i.e., Abort, Cancel, Ignore, No, None, OK, Retry, Yes).
I have tested this in my test application by setting and removing the DialogResult property of the OK in this manner, and it ran alright. Hope it solves your problem as well.
|
|
|
|
|
Hmmm - thanks for all this, it obviously explains one problem ( the double close behaviour ), although I'm surprised to hear that the buttons could be set this way, as I set them to none explicitly. This could be an indicator that the resx file is in a mess.
And if the resx file is screwed, that would explain the other behaviour as well.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|