| Adding multiple enum items |
|
 |
Index ‹ DotNet ‹ Visual C#.Net
|
- Previous
- 1
- Dotnet >> .NET 1.1 (and possibly 1.0 also) Threads leaking "Event" handles. [BUG??]Hi,
Threads in the .NET Framework 1.1 (and possibly in 1.0 also) leak "Event"
handles, by Event handles I mean Win32 Event handles which can be monitored
using the ProcessExplorer from www.sysinternals.com, or even simply look at
the Handle count in the good old windows TaskManager.
To demonstrate the problem, all I did was created a basic Win Forms
application and with Main implemented as:
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
and Form's constructor as
public Form1()
{
while(true)
{
Thread thread = new Thread( new ThreadStart( ThreadProc) );
thread.Start();
Thread.Sleep(1000);
GC.Collect();
}
}
and the ThreadProc is implemented simply as
protected void ThreadProc()
{
Thread.Sleep(100);
return;
}
Now you let it run for a while and monitor the handle count using the
ProcessExplorer or TaskManager to can see that the thread count becomes more
or less constant after a bit (which means that an equilibrium is reached in
which the threads being created and thread which die is same), you will note
that the Handle count keeps on increasing. I have monitored upto 10000
handles after which I killed the application.
Now, this seems like a bug. Has someone got any explaination for this and
possibly a workaround. BTW, I also tried changing the attribute on Main from
STAThread to MTAThread with no change in behavior.
Any help/suggestions would be appreciated.
thanks,
Rohit
- 2
- Dotnet >> Dataset alternative to stored proc row resultsUsing the reader object I'm not having a problem retrieving stored
procedure return values, but I'm having trouble getting at the actual
data coming back in the row results. My first impulse would be to fill
a dataset, but I'd prefer to return the results in a more generic
fashion, hopefully via the reader. Again, these are row results coming
back from a proc, so there won't be any named variables to work with.
Any suggestions?
Thanks in advance,
Al
- 3
- Visual C#.Net >> Adding Items to ComboboxI am using a C# combobox control. There are too many items to add right from
the start, I want to add 20 or so, then when the user cursors down to the
last one and cursors down again, I will add the next 20 so that they can
continue. Is there an event for when the user has reached the end of the list?
The only other was I can think of to handle it would be to capture each time
they pressed the up or down arrow, then see if the value changed, and if not,
add items. Is there not a better way than that? Thanks.
- 4
- Microsoft Project >> Overallocation issueHi All,
I have also another overallocation problem and I got crazy with it last
2 months. It became quite critical for me and still can't solve it.
I've simplified it (8 basic tasks over 8 phase), 4 resources, single
resource assignments, work entered. Read all articles, watched training
movies, searched online helps and digged news groups.
I desperately need a help for that. I will be happy if you can help me
or forward me to somewhere.
Best Regards
- 5
- ADO >> TableAdapter update fail with inconsistent paramterI use Wizard to build TableAdpater
My tableadapter is make by a select command:
Select ID, Name form Test
It update generate a update command:
Update Test set ID=@ID, Name=@Name where ID=@Orginial_ID
But when I use a gridview with the TableAdpater and set the DataMemberKeys
to ID, and Update data with this gridview, it fail with message:
can find update method with parameter Name,@Orginial_ID
I think the girdview did'nt pass the first ID parameter to TableAdpater.
How can I do?
- 6
- Visual C#.Net >> maximize formsI can set the maximizeBox property. But I didn't find a method to maximize a
MDI child form.
So I must do a duoble click at the maximize box.
Anybody know a maximize function or method?
Thank in advance
Thomas
- 7
- Net Framework >> XMLDocument.LoadXML(mystring)Hi I'm trying to use the loadXML method of the
XMLDocument but i'm recieving the following error.
'<', hexadecimal value 0x3C, is an invalid attribute
character
I have a <br> tag in my string which is causing the
problem, does anyone know how i can get around this?
Thanks
N
- 8
- Microsoft Project >> Actual Duration vs. DurationWhen would you use Actual Duration and when would you use
Duration?
I went to help to find:
The Duration field is the total span of active working
time for a task. This is generally the amount of working
time from the start to the finish of a task.
The Actual Duration field shows the span of actual
working time for a task so far, based on the scheduled
duration and current remaining work or percent complete.
This program is too confusing
Thank you
- 9
- Visual C#.Net >> Get the plain text from html stringI am wondering what is the fastest way to get plain text such as "abc def 12"
from an HTML string.
I can parse it, but not sure how to deal with those special characters, such
as & and >. Is there an API to get the right plain text?
TIA.
- 10
- Winforms >> ListView.tag lost objectHi,
I have a Form with two ListViews; The ListViews are diplayed on the
Design surface, but I progmatically adding the items to each ListView.
When adding the items to the list view I am iterating through and
setting the following:
...
With myListViewItem
.Text = drArticles("Title").ToString
.ToolTipText = drArticles("Summary").tostring
.Tag = CType(drArticles("ID"),Guid)
End With
myListView.Items.Add
...
This works fine and the items are displayed.
The problem arises when I respond to a SelectedIndexChanged event I can
retrieve the .ToolTipText and .Text values from then
SelectedListViewItemCollection but the .tag property is always empty (it
knows the object type is GUID but does not have the value. I know the
value is being set as I can set the ToolTipText to same ID as the TAG
and it is stored correctly.
Any ideas?
Many thanks in advance
- 11
- Visual C#.Net >> COM interoperatability using PInvoke (SEH Exception)Hi All,
I am trying to call COM Component in .NET using PInvoke.
In the following scenario, ( I am getting an exception called SEH -
External component has thrown an exception)
UnManaged Code
---------------
virtual HRESULT IDispatch::GetIDSOfNames(const IID & riid, LPWSTR *
rgizNames, UINT CNames, LCID lcid, DISPID *rgDispID)
Managed Code (I have rewritten)
------------
int GetIDsOfNames ([In] System.Guid guid, ref System.String[]
rgNames,[In] System.UInt32 cNames, [In] System.UInt32 lcid,
[Out] out long[] dispID);
Public Test()
{
AXIDispatch pIScriptDispatch;
String[] wszScriptFunctions = new String[1];
wszScriptFunctions[0] = "entryMethod";
long[] dispIDFunctions = new long[1];
pIScriptHost.GetScriptDispatch (out pIScriptDispatch);
IntPtr p = Marshal.GetIDispatchForObject(pIScriptHost);
IntPtr ppv;
Marshal.QueryInterface(p,ref diug,out ppv);
pIScriptDispatch = (AXUtil.AXIDispatch)Marshal.GetObjectForIUnknown(ppv);
try
{
pIScriptDispatch.GetIDsOfNames (guid,ref wszScriptFunctions, 1,
1033, out dispIDFunctions);
}
catch (Exception ex)
{
Console.WriteLine (ex.ToString ());
}
}
If I execute Test() I will be getting the following Exception for
Invoking "GetIDsOfNames(....)"
System.Runtime.InteropServices.SEHException: External component has
thrown an exception.
What could be the reason to get this kind exeception, I don't know
what to do in order to handle it error. Could anyone
kindly help me to solve ? I will greatly appreciate.
Thanks & Regards
R. Muthiah Samy
- 12
- Dotnet >> Composite UI application Block - Thread Safe?Does anyone have any input on setting up my CAB application so that the
application is thread safe, and cached appropiately? I read that this
can be managed through Services, and dynamic injection. On the
contrary, I was told that this can be handled using Enterprise Library
cached application block. Last, but not least, i read you can implement
this at the class level, creating immutable classes, and caching them
accordingly. Any suggestions would be greatly appreciated?
- 13
- ADO >> Download to Excel from SQL stored procedureCan anyone give me a simple bit of code to run on my website offering
a download to excel facility from a SQL stored procedure? I know how
to get the data from the stored procedure, but how do I let the user
download it to Excel, as I have seen done on some other websites?
- 14
- Dotnet >> Localized Exception Messages in WinFormsSystem exception messages in VS2005 are given in the local language.
Sometimes it is nice, but often it is quite inconvenient - try looking up
MSDN or Google with a localized message!
So, after having received a rather obtuse message concerning a P/Invoke
error, I spent some time getting rid of this unwanted feature, and I wish to
share with you the results.
First, my solution: In the Load event of the main form, add:
Thread.CurrentThread.CurrentUICulture = new
System.Globalization.CultureInfo ("en-US");
Now, the explanation:
Visual Studio Debugger, How to: Find Out More About an Exception with the
Exception Assistant says quite clearly:
"Message: Message associated with the exception. This is displayed in the
language specified by the CurrentUICulture property of the thread that
throws the exception."
So it is a feature, albeit not well considered.
Where does CurrentUICulture come from?
The help at NET Framework Class Library, Thread.CurrentUICulture Property,
advises:
Application.Run(new UICulture());
But this is wrong, Application.Run does not take a culture parameter, and
the Application.CurrentCulture property does not affect the behavior of the
exception assistant - CurrentCulture and CurrentUICulture are not the same
thing! CurrentUICulture is a property of the thread, and is not affected by
either of the application CurrentCulture or the assembly
NeutralResourcesLanguage attribute. It is the language specified in the
control panel regional and language options.
The assembly Culture attribute may not be used: "Information on the culture
or language the assembly supports. This information should be used only to
designate an assembly as a satellite assembly containing culture- or
language-specific information. (An assembly with culture information is
automatically assumed to be a satellite assembly.)"
So we are left with dynamically modifying the thread CurrentUICulture.
In development I can make it depend on #if DEBUG. But what if a user in
another country gets a system exception using my software? I will get the
error message in his language and what could I do with it?
See http://msmvps.com/blogs/calinoiu/archive/2006/06/30/103426.aspx
JR
- 15
- Net Framework >> Assembly info file..Can I give a variable in the assembly info file?
Say like
<Assembly: AssemblyTitle(var1)>
var1 is a static variable in my project that is common for the project
VJ
|
| Author |
Message |
MikeWiMSFT

|
Posted: Sun May 23 13:09:18 CDT 2004 |
Top |
Visual C#.Net >> Adding multiple enum items
probably simple but need quick answer if possible. How do I add multiple
enum values to a particular property
e.g. in Vb you would have added them (bit like)
myDataView.RowStateFilter = DataViewRowState.CurrentRows +
DataViewRowState.ModifiedOriginal;
Thanks in advance.
--
Br,
Mark Broadbent
mcdba , mcse+i
=============
DotNet401
|
| |
|
| |
 |
Francois

|
Posted: Sun May 23 13:09:18 CDT 2004 |
Top |
Visual C#.Net >> Adding multiple enum items
"Mark Broadbent" wrote :
> probably simple but need quick answer if possible. How do I add multiple
> enum values to a particular property
>
> e.g. in Vb you would have added them (bit like)
> myDataView.RowStateFilter = DataViewRowState.CurrentRows +
> DataViewRowState.ModifiedOriginal;
in C# you can use :
myDataView.RowStateFilter = DataViewRowState.CurrentRows |
DataViewRowState.ModifiedOriginal;
--
Francois Beaussier
EMail@HideDomain.com
|
| |
|
| |
 |
Mark

|
Posted: Sun May 23 13:56:07 CDT 2004 |
Top |
Visual C#.Net >> Adding multiple enum items
Thanks again Francois. Gold Star for you!
--
Br,
Mark Broadbent
mcdba , mcse+i
=============
"Francois Beaussier" <EMail@HideDomain.com> wrote in message
news:%EMail@HideDomain.com...
> "Mark Broadbent" wrote :
>
> > probably simple but need quick answer if possible. How do I add multiple
> > enum values to a particular property
> >
> > e.g. in Vb you would have added them (bit like)
> > myDataView.RowStateFilter = DataViewRowState.CurrentRows +
> > DataViewRowState.ModifiedOriginal;
>
> in C# you can use :
>
> myDataView.RowStateFilter = DataViewRowState.CurrentRows |
> DataViewRowState.ModifiedOriginal;
>
> --
> Francois Beaussier
> EMail@HideDomain.com
>
>
|
| |
|
| |
 |
| |
 |
Index ‹ DotNet ‹ Visual C#.Net |
- Next
- 1
- Visual C#.Net >> KeyPreview now useable? (VS 2005)I have always found the form-level KeyPreview feature near useless, as
there was a bug that allowed ComboBoxes to ignore it. In VS 2005 I've
confirmed that it now woks in Combos. Is there anything else to be
concerned about, or can we now use this to our heart's content when we
want to pre-process input?
Bob
- 2
- ADO >> nvarchar Sql data typeHi
If the table column is defined as folows:
FullName nvarchar 20
Does this let me add a string of maximume 20 characters? or is it limited to
20 bytes length?
Thanks,
Ronen
- 3
- Visual C#.Net >> ArrayList.RemoveAt(i)Hi All,
I've done the same things for another array list like resetting the
datasource and its working fine but this time for a separate case i still
get the same error "index out of range"
And like before, the arraylist that is being binded is deleting correctly
from 4 items down to 3 etc. Do anyone have any ideas?
Thanks in advance
Alex Ting
""Jeffrey Tan[MSFT]"" <v-jetan@online.microsoft.com> wrote in message
news:Y8BBI8DpDHA.1544@cpmsftngxa06.phx.gbl...
>
> Hi Alex,
>
> You should set DataGridTableStyle's MappingName to "ArrayList", then set
> DataGridColumnStyle's MappingName to Arraylist's public property.
> When deleting the arraylist member, you should refer to the
> CurrencyManager(Manages the collection of BindingManagerBase objects )
> which can get from BindingContext item.
> You should decrease CurrencyManager.Position property.
> Then, you can delete an item of arraylist and update the CurrencyManager.
>
> There is a sample project(You should download the entire project from a
> link in this article) in the post I last replied you. It provides you a
> detailed implementation of operating the Arraylist databinding. This
sample
> project works well on my machine, and I think it will meet your need
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>
> --------------------
> | From: "Alex Ting" <ating@learningfast.com>
> | References: <OaUw5A3nDHA.392@TK2MSFTNGP11.phx.gbl>
> <MhzPQQ3oDHA.2624@cpmsftngxa06.phx.gbl>
> | Subject: Re: ArrayList.RemoveAt(i)
> | Date: Thu, 6 Nov 2003 13:34:30 +1100
> | Lines: 285
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | Message-ID: <e81VU6ApDHA.964@TK2MSFTNGP10.phx.gbl>
> | Newsgroups: microsoft.public.dotnet.languages.csharp
> | NNTP-Posting-Host: learningfast2.learnfast.monash.edu.au 130.194.247.2
> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
> | Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.languages.csharp:197066
> | X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
> |
> | Hi Jeff,
> |
> | Thanks for your reply.
> |
> | the getQuestions simply returns the arrayList
> |
> | public Learningfast.QGM.QuizList getQuestions()
> |
> | {
> |
> | return this.myQuestions;
> |
> | }
> |
> | The mapping name is set to this but this is still not working. I even
set
> | the mapping name to "ArrayList" but to no avail.
> |
> | Thanks in advance.
> |
> | Alex Ting
> |
> |
> | ""Jeffrey Tan[MSFT]"" <v-jetan@online.microsoft.com> wrote in message
> | news:MhzPQQ3oDHA.2624@cpmsftngxa06.phx.gbl...
> | >
> | > Hi Alex,
> | >
> | > Sorry for letting you wait for so long time.
> | > I think your code snipet is not integrated. There is nothing code
> related
> | > to getQuestions() method.
> | > But I still can give you some suggestion.
> | > For datagrid to bind to the arraylist, you should set the MappingName
> | > property to "ArrayList" not others. This rule can be found in MSDN
> | document
> | > in DataGrid(WinForm).
> | > I think if you set the correct binding, the datagrid will reflect the
> | > source arraylist correctly.
> | >
> | > For a sample of how to bind arraylist to datagrid, you can refer to:
> | > http://www.syncfusion.com/FAQ/WinForms/FAQ_c43c.asp#q818q
> | >
> | > If you still have anything unclear, please feel free to let me know.
> | >
> | > Best regards,
> | > Jeffrey Tan
> | > Microsoft Online Partner Support
> | > Get Secure! - www.microsoft.com/security
> | > This posting is provided "as is" with no warranties and confers no
> rights.
> | >
> | > --------------------
> | > | From: "Alex Ting" <ating@learningfast.com>
> | > | Subject: ArrayList.RemoveAt(i)
> | > | Date: Fri, 31 Oct 2003 16:30:57 +1100
> | > | Lines: 201
> | > | X-Priority: 3
> | > | X-MSMail-Priority: Normal
> | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | > | Message-ID: <OaUw5A3nDHA.392@TK2MSFTNGP11.phx.gbl>
> | > | Newsgroups: microsoft.public.dotnet.languages.csharp
> | > | NNTP-Posting-Host: learningfast2.learnfast.monash.edu.au
130.194.247.2
> | > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
> | > | Xref: cpmsftngxa06.phx.gbl
> | microsoft.public.dotnet.languages.csharp:195620
> | > | X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
> | > |
> | > | Hi Everybody,
> | > |
> | > | I have an issue about deleting an object from an arrayList.
> | > |
> | > | I've bounded a datagrid using this code
> | > | where it will first run through all of the code in loadQuestions()
and
> | > bind
> | > | a arrayList to the datagrid.
> | > |
> | > | private void BindQuestions()
> | > |
> | > | {
> | > |
> | > | dataGridQuestions.DataSource= this.AppQuiz.getQuestions();
> | > |
> | > | this.toolBarBtnSave.Enabled=true;
> | > |
> | > | this.toolBarBtnDel.Enabled=true;
> | > |
> | > | }
> | > |
> | > |
> | > |
> | > | public void loadQuestions()
> | > |
> | > | {
> | > |
> | > | this.BindQuestions();//this.AppQuiz.getQuestions();//AppQuiz();
> | > |
> | > | if(this.DataGridSet==false)
> | > |
> | > | {
> | > |
> | > | DataGridTableStyle gs = new DataGridTableStyle(); // gs =
Grid
> | > Style
> | > |
> | > |
> | > | gs.MappingName = AppQuiz.getQuestions().GetType().Name;
> | > | //dummyDataArr.GetType().Name;
> | > |
> | > | gs.AllowSorting = true;
> | > |
> | > | gs.AlternatingBackColor = System.Drawing.Color.AntiqueWhite;
> | > |
> | > |
> | > | DataGridTextBoxColumn cs2 = new DataGridTextBoxColumn();
> | > |
> | > | cs2.MappingName = "QuestionID";
> | > |
> | > | cs2.HeaderText = "No.";
> | > |
> | > | cs2.Alignment = HorizontalAlignment.Left;
> | > |
> | > | cs2.Width = 33;
> | > |
> | > | cs2.ReadOnly = true;
> | > |
> | > |
> | > | gs.GridColumnStyles.Add(cs2);
> | > |
> | > |
> | > | DataGridBoolColumn cs = new DataGridBoolColumn(); // cs =
> Column
> | > | Style
> | > |
> | > | cs.MappingName = "Publish";
> | > |
> | > | cs.HeaderText = "Publish";
> | > |
> | > | cs.Width = 75;
> | > |
> | > | gs.GridColumnStyles.Add(cs);
> | > |
> | > | cs = new DataGridBoolColumn();
> | > |
> | > | cs.MappingName = "Required";
> | > |
> | > | cs.HeaderText = "Mandatory";
> | > |
> | > | cs.Width = 75;
> | > |
> | > | cs2.ReadOnly = true;
> | > |
> | > | gs.GridColumnStyles.Add(cs);
> | > |
> | > | cs2 = new DataGridTextBoxColumn();
> | > |
> | > | cs2.MappingName = "QuestionType";
> | > |
> | > | cs2.HeaderText = "Question Type";
> | > |
> | > | cs2.Alignment = HorizontalAlignment.Center;
> | > |
> | > | cs2.Width = 80;
> | > |
> | > | cs2.ReadOnly = true;
> | > |
> | > | gs.GridColumnStyles.Add(cs2);
> | > |
> | > | cs2 = new DataGridTextBoxColumn();
> | > |
> | > | cs2.MappingName = "Ask";
> | > |
> | > | cs2.HeaderText = "Question";
> | > |
> | > | cs2.Alignment = HorizontalAlignment.Left;
> | > |
> | > | cs2.Width = 255;
> | > |
> | > | cs2.ReadOnly = true;
> | > |
> | > | gs.GridColumnStyles.Add(cs2);
> | > |
> | > | dataGridQuestions.TableStyles.Add(gs);
> | > |
> | > |
> | > | }
> | > |
> | > | panelDgQuestions.Show();
> | > |
> | > | panelSplash.Hide();
> | > |
> | > | }
> | > |
> | > |
> | > |
> | > | And then after that, they can delete a row from the datagrid. Then
> this
> | > | function is called
> | > |
> | > |
> | > |
> | > | /// <summary>
> | > |
> | > | /// this will remove the questions and then shuffle up all the
> questions
> | > | after it
> | > |
> | > | /// </summary>
> | > |
> | > | /// <param name="questionID">question ID to remove</param>
> | > |
> | > | public void removeAndShuffle(int questionID)
> | > |
> | > | {
> | > |
> | > | for(int i=0; i< this.myQuestions.Count; i++)
> | > |
> | > | {
> | > |
> | > |
> | if(((Learningfast.QGM.Question)this.myQuestions[i]).QuestionID
> | > | == questionID)
> | > |
> | > | {
> | > |
> | > | this.myQuestions.RemoveAt(i);
> | > |
> | > | }
> | > |
> | > | }
> | > |
> | > | }
> | > |
> | > |
> | > |
> | > | In debug mode, for example if there were 2 rows, it is now 1 row and
> | > | everything seems fine, but when i rebind the datagrid with the
> arraylist
> | > | after an object has been removed,
> | > |
> | > | private void BindQuestions()
> | > |
> | > | {
> | > |
> | > | dataGridQuestions.DataSource= this.AppQuiz.getQuestions();
> | > |
> | > | this.toolBarBtnSave.Enabled=true;
> | > |
> | > | this.toolBarBtnDel.Enabled=true;
> | > |
> | > | }
> | > |
> | > | Mind you it does not run through the initializing statements of the
> | > | datagrid, it just rebinds the datasource. And then at this point
when
> | the
> | > | datagrid is meant to be displayed, it gives me an error index [index
> | > number
> | > | that was deleted] is out of bounds.
> | > |
> | > | Can someone please tell me whats happening? I've read up in several
> | cases
> | > | and usually this means that I'm trying to bring up the object that
was
> | > | deleted but I'm just changing the datasource to the amended
arraylist.
> | > Could
> | > | this have to do with my existing datagrid where i'm not initializing
> it
> | > | again? because I've tried that and it also brings up an error saying
> | that
> | > | i'm using the same "mapping name"
> | > |
> | > | Thanks in advance.
> | > |
> | > | Kind Regards
> | > |
> | > | Alex Ting
> | > |
> | > |
> | > | ---
> | > | Outgoing mail is certified Virus Free.
> | > | Checked by AVG anti-virus system (http://www.grisoft.com).
> | > | Version: 6.0.532 / Virus Database: 326 - Release Date: 27/10/2003
> | > |
> | > |
> | > |
> | >
> |
> |
> | ---
> | Outgoing mail is certified Virus Free.
> | Checked by AVG anti-virus system (http://www.grisoft.com).
> | Version: 6.0.536 / Virus Database: 331 - Release Date: 3/11/2003
> |
> |
> |
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.542 / Virus Database: 336 - Release Date: 18/11/2003
- 4
- ADO >> Problem with disable msde connection poolHello,
To resotre MSDE database, the connection pool must be disabled. I set
pooling=false in the connection string, i.e.,
SqlConnection conn = new SqlConnection("server=(local)\\NetSDK;
database=mydb; uid=sa; password=abc; pooling=false;");
It seems that the connection pool was not disabled. Here are the error
messages I got:
[Microsoft][ODBC SQL Server Driver][SQL Server]Exclusive access could
not be obtained because the database is in use.
[Microsoft][ODBC SQL Server Driver][SQL Server]RESTORE DATABASE is
terminating abnormally.
Any ideas? Are there any other ways to disable the connection pool?
Any help would be appreciated!
Mandy
- 5
- ADO >> MSDE and TransactionScopeI have a C# application that applys a set of scripts to a database to create
the structures. When each script is applied, I encapsulate the call within a
TransactionScope. Everything works fine on SQL Server 2000 sp4, 2005 sp1,
and Express 2005 sp1 databases.
On MSDE2000 SP4, I consistently get transaction timeouts on my scripts.
However, it is never the same script. These are the same scripts I use on
other database, so I am confident that the scripts themselves are fine.
Everything is running locally on one machine. MSDTC is running. I've tried
restarting the services, restarting the machines, and connection pooling
seems to be ok, and I'm running out of ideas to check.
Has anyone had a similar experience or can recommend something to check?
- [System.Data.SqlClient.SqlException] {"Import of MSDTC transaction
failed: XACT_E_NOTRANSACTION."} System.Data.SqlClient.SqlException
Number 8509
- 6
- Net Framework >> Having trouble deploying Custom User Control to a container ...If I develop a user control that is made from intrinsic windows controls such
as text box, etc, I can successfully deploy it to the the browser and see it
instantiated.
but if I add a third party control to the custom control, then I have
difficulty instantiating it.
I guess this has to do with .Net framework security.
I have done my best to change the security policies on the local computer to
allow the Custom User Control to run, but had no success.
I have dveloped and deployed the user control by following the steps
provided at the following URL:
http://www.c-sharpcorner.com/Code/2003/March/ActiveXInNet.asp
Is there any way I can develop a user control in .Net that includes a third
party control and instantiate into a container?
All helpful comments will be appreciated.
Thanks,
Mehran Sedaghatpour.
- 7
- Net Framework >> Short display for long filenamesHello,
as most of you know, some programs that handle files have a "recent files"
feature, that is mostly a menu item within the file menu that shows the
last documents the user had opened. Visual studio .net gives you an
example.
This example shows as well that long filenames will be displayed shortened
to fit the menu item, e.g.
C:\Documents and settings\John Doe\My files\XYZ\document.xyz
might be displayed as
C:\Documents and settings\ ... \XYZ\document.xyz
As I would like to have this feature in my own brilliant and amazing
helloWorld-application, too, I'm wondering if there isn't a function in
the .net framework that returns the shorter version of a full path that
exceeds a specified length.
Of course, it is possible - actually for me - to parse the string for
myself, but I would not like to reinvent the wheel.
Just to prevent misunderstandings: I don't mean that kind of short filenames
returned by the GetShortPathName-API-function like "C:\Documn~1\John~1" ...
So: Did I overlook something in the .net documentation?
Regards Daniel
--
http://www.bolege.de
E-mails to specified address will NOT be read.
Please use db[at]bolege[dot]de instead.
- 8
- Net Framework >> Nullable boolean true on webservice response comes across as nullHello all,
I'm working on a web app that we converted over to asp 2.0 recently and
here's the issue I ran into:
We use a java webservice to retrieve data and display this data to the user.
This was working in 1.1 and nothing changed around this particular webservice
call on either side after the switch to 2.0. The webservice response is an
array of value objects and the value object contains a boolean. I intercepted
the response with Fiddler and verified that the boolean was set to either
true or false on all the vo's in the array. But after the response object was
created and I could look at it in the code while debugging, the (nullable)
boolean field in every vo in the array was null.
To fix this temporarily, I had the webservice provider change the boolean
field to a 'NullableBoolean' class that contained a boolean value - this way,
the correct value came across and I could work with it.
I'm not sure if this is helpful, but there's one more detail I noticed -
The xml doc I intercepted with Fiddler looks something like this
('processed' is the boolean variable):
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"...>
<env:Body env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
...
<responseVos...>
...
<ResponseVo ...>
...
<processed href="#ID_4"/>
...
</ResponseVo>
...
</responseVos...>
...
<xsd:boolean xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:type="xsd:boolean" id="ID_4">true</xsd:boolean>
...
</env:Body>
</env:Envelope>
This is working for now but I think I shouldn't have to have my webservice
provider fix my problem, right? Any help in solving this problem would be
greatly appreciated.
--
ak
- 9
- Visual C#.Net >> CollectionBase in Net1.1 and Collection in Net 2.0Hi,
I have some collections that inherit from CollectionBase in Net 1.1
In these collection I override the OnRemove, OnRemoveComplete, ...
I would like to to move them in Net 2.0 but in this version these protected
methods don't exist
What is the best way?
Thank's in advance
- 10
- Dotnet >> PDF's Internet Explorer 7Ever since I installed IE 7 PDF's on several web sites do not appear for me
to print or download. Is there a setting I need to adjust. This happens only
on a few web sites
- 11
- Dotnet >> Formating a text boxI am being very dumb... I am coverting an invoice value to a decimal and
displaying the result on a VB.net 2003 form. However, I only want to display
the result to 2 decimal places and I am struggling to it - sorry for such an
easy question!
Can somebody advice me how to achieve this?
--
Thanks
Bill Partridge
- 12
- Visual C#.Net >> BinaryReader munges dataI'm about to rip out what little hair I have left; I have a class that
uses a BinaryReader, and the data is getting munged. A subset of the
code follows; I've removed the parts that aren't relevant.
What's really strange is that it reads the file just fine until the
272nd call to the Read method of the class, at which point it begins
munging the data.
Any thoughts would be greatly appreciated; I've tried reading by byte,
as well as reading blocks, and it makes no difference.
-Kevin
public class HeaderStream
{
private const int c_BlockSize = 680;
private System.IO.BinaryReader str;
public HeaderStream(string path)
{
FileStream s = new FileStream(path,
FileMode.Open,
Read);
str = new BinaryReader(s);
}
public OWHeader Read()
{
byte[] buf = new byte[c_BlockSize];
int i;
i = str.Read(buf, 0, c_BlockSize);
if (i != c_BlockSize)
throw new EndOfStreamException(
String.Format(
"End of stream reached with bytes left to read"));
return new OWHeader(buf);
}
}
- 13
- Visual C#.Net >> Access ModifiersHi,
Is it possible to declare a variable or array in the class that is
accessible to all the methods in the class? For the example below, I would
like to make the variable lnVar1 accessible to both methods m1 and m2 but I
am getting an error. Is there another way to do this?
Thanks
Roy
using System;
using System.Collections.Generic;
using System.Text;
namespace cClasses
{
class Program
{
static void Main(string[] args)
{
AA2.m1();
}
}
}
public class AA2
{
protected int lnVar1 = 0;
public static void m1()
{
Console.Write("M1 {0}", lnVar1);
}
public static void m2()
{
Console.Write("M2 {0}", lnVar1);
}
}
- 14
- Visual C#.Net >> Programmatically disabling Windows Control EventsHi
I wanted to programmatically disable events like SelectedIndexChanged without
using a boolean flag, which indeed I find a quick and dirty solution. So, I
found a
piece of code that do this more elegant:
* How to disable event in C#?
Link: http://tinyurl.com/alsge
Group: microsoft.public.dotnet.framework.compactframework
But I saw it is limited to ComboBoxes and to the SelectedIndexChanged Event
and
I want to generalize it to an object of type control and to every possible
event. To
give you an idea, I will post some of my ugly code:
public static EventHandler DisableSelectedIndexChanged(Control control)
{
FieldInfo fieldInfo;
object fieldObject;
EventHandler handler = null;
fieldInfo = control.GetType().GetField("SelectedIndexChanged",
BindingFlags.Instance | BindingFlags.NonPublic);
if (fieldInfo != null)
{
fieldObject = fieldInfo.GetValue(control);
if (fieldObject is EventHandler)
{
handler = (EventHandler)fieldObject;
//This is the part I want to avoid
if (control is ComboBox)
((ComboBox)control).SelectedIndexChanged -= handler;
else if (control is ListBox)
((ListBox)control).SelectedIndexChanged -= handler;
else if (control is ListView)
((ListView)control).SelectedIndexChanged -= handler;
else if (control is TabControl)
((TabControl)control).SelectedIndexChanged -= handler;
}
}
return handler;
}
Is it possible to avoid the casting and get a pointer to the
SelectedIndexChanged
property, then apply the -= operation over it? How? As I could understand,
FieldInfo.GetValue(control) only returns the handler, but not the
SelectedIndexChanged property.
Thanks in advanced,
Josef
- 15
- Net Framework >> EMBEDDING images - System.Web.MailHi, I hope there is someone reading this that has the answer, Please Help!
I have the need to send a html email via asp.net. its easy enough to send
an html email and add attachments.
My question is, how to you set the Content-Location of each attachment in
the mail headers so that the images are embedded in the html email rather
than attached?
This is my code:
private void Page_Load(object sender, System.EventArgs e)
{
MailMessage objEmail = new MailMessage();
objEmail.From = aspnet@domain.com;
objEmail.Subject = "news flash ";
string body = "<html>.....
{some html code with images as <img src=\"news_r1_c1.jpg\"> ... etc
</html>";
objEmail.Body = body;
objEmail.Priority = MailPriority.Normal;
objEmail.BodyFormat = MailFormat.Html;
MailAttachment i1 = new
MailAttachment(Server.MapPath("images/news_r1_c1.jpg"));
MailAttachment i2 = new
MailAttachment(Server.MapPath("images/news_r1_c3.gif"));
MailAttachment i3 = new
MailAttachment(Server.MapPath("images/spacer.gif"));
MailAttachment i4 = new
MailAttachment(Server.MapPath("images/news_r4_c1.jpg"));
MailAttachment picture = new
MailAttachment(Server.MapPath("images/default.jpg"));
objEmail.Attachments.Add(i1);
objEmail.Attachments.Add(i2);
objEmail.Attachments.Add(i3);
objEmail.Attachments.Add(i4);
objEmail.Attachments.Add(picture);
string sendto = Request.Form["recipients"];
string[] recipients= sendto.Split(',',';');
foreach(string recipient in recipients)
{
objEmail.To = recipient.Trim();
SmtpMail.SmtpServer = "smtp.server,com";
try
{
SmtpMail.Send(objEmail);
}
catch (Exception exc)
{
Response.Write("Send failure: " + exc.ToString());
}
}
}
as said, html email is coming through fine, images are in email as
Attachments, but DON'T display inline with the page (even though the
attachments are named correctly corresponding to the image names in the HTML
(<img src="imagename.jpg"> where imagename.jpg is attached).
I have sent HTML emails with embedded images in Classic ASP using CDONTS
quite easily, i need to do the same in .NET!
[FYI code to attach in ASP is:
objMail.AttachURL server.MapPath("images/imagename.jpg"), "imagename.jpg"
]
a quick look at the message source shows this at the top of the part that
holds the binary information about the image, in the email source:
for the ASP version (that works) :
------=_NextPart_000_000A_01C3EF89.62C8CA30
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-Disposition: attachment
Content-Location: news_r1_c1.jpg
in the ASP.NET version (doesn't show images inline)
------=_NextPart_000_005D_01C3F184.ECF34990
Content-Type: image/jpeg;
name="news_r1_c1.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="news_r1_c1.jpg"
notice how there is no Content-Location with the image name in the .NET
version, this is obviously needed to tell the mail client where the attached
images should be displayed in the HTML email.
Now does anyone know how to set this in the .NET mail object??
any help/leads in the right direction are appreciated.
The doesn't seem to be anywhere to set this property in the MailAttachment,
or MailAttachments.Add methods, and i couldn't find any answers in the docs
Please help
Thanks
Tim
PS. (although i'm using c#, vb code will do if you code in VB.NET)
|
|
|