|
Yes I did, but for some reason the Detail property is visible in the quick watch but when I try to write it by using the intellisense and get those on the screen or some where in the log I am not able to access it, any advice would be very very appreciated, try it, you will have a detail property and try to write them on the screen or some where to persist, you will not find it in the code to write it.
|
|
|
|
|
The Exception class doesn't have a Details property, so you're code can't see it. You're basically casting the exception object back up to the root Exception class, stripping all the properties that don't exist in the Exception class.
If you want to catch a specific type of exception, you have to put that type in the catch statement:
try
{
}
catch (SomeSpecificExceptionClass ex)
The QuickWatch window uses the actual type of the class to fill in all available properties. That's why you see it in QuickWatch but the code can't.
|
|
|
|
|
Anyways to bring that up into the code of the catch block? 
|
|
|
|
|
Change your exception handler to the type shown in the quick watch.
This space for rent
|
|
|
|
|
|
Yes thanks my friend, just trying to get work around if any, since the Inner Exception and Message properties both are coming null from the Service.
Yeah I agree, you did give me idea what it is actually and thank you very much for the help.
|
|
|
|
|
|
Yeah I understand that, but I am seeing the Detail property in the Quick-watch but not in the intellisense and while trying to code the values, just try it, you can understand, I don't know why is it happening.
|
|
|
|
|
You just need to change your code to display all the information that the exception provides. As I said previously, look at the documentation for what is available.
|
|
|
|
|
|
I have 2 .net forms, each with their own BindingSource which I set to go after the same DataTable. The table is filled early on with 35 rows. One of the BindingSources has a filter set when the form loads, which makes the result set 4 rows. When I go back to the first form, the row count has gone down to 4 - if I set that BindingSource filter to "", the count returns to 35.
It looks as if the two binding sources are sharing stuff, where changing the filter on one affects the other.
Any explanation for this? I am working around it but would like to understand the mechanism.
Bob
|
|
|
|
|
It's the sharing of the same DataSource that is the issue. When you set the Filter to a none null value, the property is passed down to the underlying data source so you are filtering on the source itself. Source[^].
This space for rent
|
|
|
|
|
Thanks, if I read the docs right, it appears if I tie the binding sources to DataViews, not the DataTable, it might work as I intend and keep the filters separate...
|
|
|
|
|
Based on my own experience, I am just need to create public static DataTable datasource which is will be consumed by that 2 or more forms...
Not just Datatable, but also collection,
We can put it on main Program.cs, let's say it glbData.
public class Program{
public static DataTable glbData;
}
usage :
DataTable dt = resultset[0];
Program.glbData = dt;
Regards
Toha
|
|
|
|
|
And how does your solution solve the problem the poster had? Go ahead and try your solution with the problem the OP had.
This space for rent
|
|
|
|
|
I have test this and the first form not affected with changes from FormMahasiswa
private void FormMahasiswa_Load(object sender, EventArgs e)
{
Form1.glbData = new DataTable();
Form1.glbData.Columns.Add("Newww", typeof(int));
Form1.glbData.Columns.Add("Drug", typeof(string));
Form1.glbData.Columns.Add("Patient", typeof(string));
Form1.glbData.Columns.Add("Date", typeof(DateTime));
Form1.glbData.Rows.Add(25, "Sample Change", "Change ", DateTime.Now);
Form1.glbData.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
Form1.glbData.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
Form1.glbData.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
Form1.glbData.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
dataGridView1.DataSource = Form1.glbData;
}
Regards
Toha
modified 17-Jan-19 3:34am.
|
|
|
|
|
I'm writing a C# WinForms .NET app in VS 2017 (v15.9.4) that is having a peculiar problem when saving a file. The file already exists and I am dutifully prompted by the SaveFileDialog to confirm overwrite with the following...
"[filename.ext] already exists. Do you want to replace it? [Yes][No]"
Problem: After clicking Yes in the above prompt, I get another prompt...
"[fullpath.ext] already exists. Do you want to replace it? [Yes][No]"
I can't find the cause of the second prompt. Here's my code to programmatically create the SaveFileDialog...
private void mnuSaveAs_Click(object sender, EventArgs e)
{
if (OurQuestion.intQuestionType <= 0)
{
MessageBox.Show("No question exists. Please create a question and click Done button before saving.",
"oops.", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Title = "Save As...";
sfd.Filter = "Trivia Question (*.tq)|*.tq";
DialogResult sfdresult = sfd.ShowDialog();
if (sfdresult == DialogResult.OK)
{
sslblCurrentOp.Text = "Saving...";
strFilePath = sfd.FileName;
mnuSave.PerformClick();
blFileNeedsSaving = false;
sslblCurrentOp.Text = "Ready.";
ssMain.Refresh();
this.Text = "TriviaPad v3.0 - " + Path.GetFileNameWithoutExtension(strFilePath);
mnuSave.Enabled = tsbtnSave.Enabled = true;
}
}
}
And here's the code for sf.SaveFile(), which is located in a .dll...
public void SaveFile(string strfilepath, clsQuestion SentQuestion)
{
Stream savestream = null;
try
{
savestream = new FileStream(strfilepath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
using (BinaryWriter bw = new BinaryWriter(savestream))
{
savestream = null;
bw.Write("3.0");
bw.Write(SentQuestion.intQuestionType);
if (SentQuestion.intQuestionType < 4)
{
bw.Write(SentQuestion.strQuestion);
bw.Write(SentQuestion.intPoints);
bw.Write(SentQuestion.blQuestionImagePresent);
if (SentQuestion.blQuestionImagePresent == true)
{
bw.Write(SentQuestion.bytQuestionImage.Length);
bw.Write(SentQuestion.bytQuestionImage);
}
bw.Write(SentQuestion.blQuestionAudioPresent);
if (SentQuestion.blQuestionAudioPresent == true)
{
bw.Write(SentQuestion.bytQuestionAudio.Length);
bw.Write(SentQuestion.bytQuestionAudio);
}
bw.Write(SentQuestion.blIncludeTimer);
if (SentQuestion.blIncludeTimer == true)
bw.Write(SentQuestion.intTimerTime);
if (SentQuestion.intQuestionType == 1)
{
bw.Write(SentQuestion.blAIsChecked);
bw.Write(SentQuestion.strAnswerA);
bw.Write(SentQuestion.blAIsCorrect);
bw.Write(SentQuestion.blBIsChecked);
bw.Write(SentQuestion.strAnswerB);
bw.Write(SentQuestion.blBIsCorrect);
bw.Write(SentQuestion.blCIsChecked);
if (SentQuestion.blCIsChecked == true)
{
bw.Write(SentQuestion.strAnswerC);
bw.Write(SentQuestion.blCIsCorrect);
}
bw.Write(SentQuestion.blDIsChecked);
if (SentQuestion.blDIsChecked == true)
{
bw.Write(SentQuestion.strAnswerD);
bw.Write(SentQuestion.blDIsCorrect);
}
}
else if (SentQuestion.intQuestionType == 2)
{
bw.Write(SentQuestion.blTrueOrFalseAnswer);
}
else if (SentQuestion.intQuestionType == 3)
{
bw.Write(SentQuestion.strFIBAnswer);
}
bw.Write(SentQuestion.strCAR);
bw.Write(SentQuestion.strIAR);
bw.Write(SentQuestion.blCARImagePresent);
if (SentQuestion.blCARImagePresent == true)
{
bw.Write(SentQuestion.bytCARImage.Length);
bw.Write(SentQuestion.bytCARImage);
}
bw.Write(SentQuestion.blCARAudioPresent);
if (SentQuestion.blCARAudioPresent == true)
{
bw.Write(SentQuestion.bytCARAudio.Length);
bw.Write(SentQuestion.bytCARAudio);
}
bw.Write(SentQuestion.blIARImagePresent);
if (SentQuestion.blIARImagePresent == true)
{
bw.Write(SentQuestion.bytIARImage.Length);
bw.Write(SentQuestion.bytIARImage);
}
bw.Write(SentQuestion.blIARAudioPresent);
if (SentQuestion.blIARAudioPresent == true)
{
bw.Write(SentQuestion.bytIARAudio.Length);
bw.Write(SentQuestion.bytIARAudio);
}
}
else if (SentQuestion.intQuestionType == 4)
{
bw.Write(SentQuestion.MatchUp.strMatchUpTitle);
bw.Write(SentQuestion.MatchUp.strTopicName);
bw.Write(SentQuestion.MatchUp.intPoints);
bw.Write(SentQuestion.MatchUp.blPenaltyPoints);
bw.Write(SentQuestion.MatchUp.blMatchUpTitleImagePresent);
if (SentQuestion.MatchUp.blMatchUpTitleImagePresent)
{
bw.Write(SentQuestion.MatchUp.bytMatchUpTitleImage.Length);
bw.Write(SentQuestion.MatchUp.bytMatchUpTitleImage);
}
bw.Write(SentQuestion.MatchUp.blStartAudioPresent);
if (SentQuestion.MatchUp.blStartAudioPresent)
{
bw.Write(SentQuestion.MatchUp.bytStartAudio.Length);
bw.Write(SentQuestion.MatchUp.bytStartAudio);
}
bw.Write(SentQuestion.MatchUp.blSoundtrackAudioPresent);
if (SentQuestion.MatchUp.blSoundtrackAudioPresent)
{
bw.Write(SentQuestion.MatchUp.bytSoundtrackAudio.Length);
bw.Write(SentQuestion.MatchUp.bytSoundtrackAudio);
}
bw.Write(SentQuestion.MatchUp.blEndAudioPresent);
if (SentQuestion.MatchUp.blEndAudioPresent)
{
bw.Write(SentQuestion.MatchUp.bytEndAudio.Length);
bw.Write(SentQuestion.MatchUp.bytEndAudio);
}
bw.Write(SentQuestion.MatchUp.intTotalMatchItems);
bw.Write(SentQuestion.MatchUp.strMatchType);
if (SentQuestion.MatchUp.strMatchType == "T")
{
if (SentQuestion.MatchUp.lstMatchItems.Count > 0)
{
for (int iii = 0; iii < SentQuestion.MatchUp.lstMatchItems.Count; iii++)
{
bw.Write(SentQuestion.MatchUp.lstMatchItems[iii].strMatchText);
bw.Write(SentQuestion.MatchUp.lstMatchItems[iii].blMatchIsCorrect);
}
}
}
else if (SentQuestion.MatchUp.strMatchType == "I")
{
for (int iii = 0; iii < SentQuestion.MatchUp.lstMatchItems.Count; iii++)
{
bw.Write(SentQuestion.MatchUp.lstMatchItems[iii].bytMatchImage.Length);
bw.Write(SentQuestion.MatchUp.lstMatchItems[iii].bytMatchImage);
bw.Write(SentQuestion.MatchUp.lstMatchItems[iii].blMatchIsCorrect);
}
}
}
}
}
finally
{
if (savestream != null)
savestream.Dispose();
}
}
My guess is that this line of code...
savestream = new FileStream(strfilepath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
...is where the problem is caused. According to MSDN documentation, a FileStream declaration also has 14 overloads besides the three necessary parameters listed above, but no further info is available on what those overloads are. If this line of code requires an overload to prevent that second confirm prompt, what is it? I can't find any info anywhere about it.
|
|
|
|
|
Your code is a bit of a mess as it's doing stuff that has nothing to do with saving the file.
DialogResult sfdresult = sfd.ShowDialog();
if (sfdresult == DialogResult.OK)
{
sslblCurrentOp.Text = "Saving...";
strFilePath = sfd.FileName;
mnuSave.PerformClick();
blFileNeedsSaving = false;
sslblCurrentOp.Text = "Ready.";
ssMain.Refresh();
this.Text = "TriviaPad v3.0 - " + Path.GetFileNameWithoutExtension(strFilePath);
mnuSave.Enabled = tsbtnSave.Enabled = true;
}
Once you check the DialogResult for OK, you're doing a ton of stuff that has nothing to do with saving the file and that's where you're problem is.
Why on earth are you calling mnuSave.PerformClick()? That just kicks off the event handler that this code is sitting in all over again, including putting up a new Save dialog!
Strip all this stuff out of the if statement, put it into it's own method for updating the user interface, forget the PerformClick call completely, and just do nothing else by save the file.
|
|
|
|
|
Hello am new to entity frame work and am trying to create two chained comboboxes. am only able to read to one combo box but failing to put a where clause in my code. Bellow is the
Try
Dim db As New SRSEntities
db.Configuration.ProxyCreationEnabled = False
cmbDistrict.DataSource = db.Districts.ToList()
cmbDistrict.DisplayMember = "DistrictName"
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
Please help how i could create a chained combo box, code samples if possible will be highly appreciated
|
|
|
|
|
Well, you need at least one combo box as the parent / "master" ... so, which one? I only see one cb.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hi, I have a problem with the answer my calculator is giving me, for example I input sin 60 and the result produced is -0.304810621102217 instead of 0.866025403.
The code I used is:
Public form
Dim operand1, operand2, ans as double
Dim operators as string
Dim n as int32
Private sub buttonsin_click
Ans = math.sin(label1.text)
Label1.text = ans
Label3.text = "sin"
Private sub buttoncos_click
Ans = math.cos (label1.text)
Label1.text = ans
Label3.text = "cos"
Please help me with the solution.
|
|
|
|
|
|
|
What is role based security ?
Please Do suggest i am beginner in this field
|
|
|
|
|
It is "security based on roles"
So instead of saying "latakurekar guards that door", you have a role that says "door guard" to which you assign latakurekar. Instead of saying "Max and Eddy guard that chicken", you have a role saying "chickenguard", and assign the role to Max and me.
This has the advantage that you put the rights on the role, not the person. It might not be impressive in the example, but if you have lots of people it is crazy to manage each persons' right in detail. Instead, they get a role assigned, and access is granted based on those roles.
Role-based access control - Wikipedia[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|