thedo's Q&A profile
.NET Development Instantiating Connection object
Hi All, i am trying to create a connection object in my form. See the code given below public class Formx:System.Windows.Forms.Form { string strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\personal\\dotnet\\Db1.mdb"; OleDbConnection con = new OleDbConnection(strConnect); } I have assigned the connection string in the variable strConnect. Now if i create the connection object in the class then it throws error. B'coz strConnect is an instance variable and it cannot be used to initialize other instance variables outside the method(in c#). so we have to make the variable either const or static. and it will not throw that error. am ok with that.. But, if i create the object in the constructor(as mentioned below ...Show All
.NET Development WebService Error --- Object reference not set to an instance of an object
hi, I am currently developing a window application utilizing webservice. the whole things run correctly, however when I run the window application on some computer, It comes out this error : System.NullReferenceException --- Object reference not set to an instance of an object it is obviously the window application cannot regconize the webserive. but it runs correctly on other computer with the same OS(windowXP SP2), what is the reason can anyone tell me it will be greatly appreciated for your reponse. My window application is developed on .Net Framework1.1, VisualStudio2003. MS SQL Server2000. Dave I defined srv1 as private variable, private FluidReportGeneratingService srv1; ...Show All
Visual Basic Stopping a timer from ticking (VB, VS05)
I am using this code to try automatically stop the System Process MDM as part of a project I am working on; Private Sub AutoCloseMDM_CheckedChanged( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AutoCloseMDM.CheckedChanged If AutoCloseMDM.CheckState = CheckState.Checked = True Then Dim T As New Timer T.Interval = 600000 T.Start() AddHandler T.Tick, AddressOf AutoStopMDM If AutoCloseMDM.CheckState = CheckState.Checked = False Then T.Stop() End If End If End Sub Private Sub AutoStopMDM( ByVal sender As Object , ByVal e As System.EventArgs) Try StopMDM.ServiceName = "MDM" StopMDM.Stop() Catch EX As InvalidCastException MessageBox.Show( "Invalid Cast Exception" ) Catch Ex A ...Show All
.NET Development ADO.NET Problems
A small problem, this code fragment doesnt work /// <summary> /// Changes a user's details /// </summary> /// <param name="username">The user to change</param> /// <param name="newUsername">The new username for the user</param> /// <param name="newPassword">The new password for the user</param> public void ChangeUser(string username, string newUsername, string newPassword) { //Create a new command component OleDbCommand SQL = new OleDbCommand(); SQL.Connection = conn; SQL.CommandText = @"UPDATE Clients SET Username = @newUser, Password = @newPassword WHERE Username = @currentUser"; OleDbParameter newUserP = new OleDbParameter(); newUserP.Value = ...Show All
.NET Development Percentage Sign in DataTable.Select()
I'm using the Select method of the DataTable in .Net 2.0 in order to return a DataRow[] which match a set of criteria. One of those columns contains strings and I want an exact match. The filter parameter of the Select method seems to use a SQL-like syntax where % acts as a wildcard character. However, it's possible for the value of the string to contain a percentage sign. Using the SQL rules solved an earlier issue I had with an apostrophe (I escaped the single apostrophe into a double apostrophe). However, nothing I try seems to convince the Select method to treat my percentage sign as a literal character instead of a wildcard. I've tried [%], \%, %% , but no luck. Both the Select() method and Expression property documentation in t ...Show All
Visual Studio Copy file peculiarity
I am copying an app.config file from the project folder to the target folder and re-naming it in line with the target file - all normal, so far. The problem is that when the file is copied, it now has an extra hex character at the end of it, (shown as a rectangle in Wordpad) preventing the configuration service from correctly parsing the file at run-time... has anyone seen this before TIA, Paul_G Build event line: COPY "$(ProjectDir)*.config" "$(TargetPath).config ...I seem to have fixed it. I changed the build line from: COPY "$(ProjectDir)\*.config" "$(TargetPath).config" to: COPY "$(ProjectDir)\app.config" "$(TargetPath).config" where I am specifically naming the config f ...Show All
Visual Studio Tools for Office VSTO Outlook 2007 Architecture Problems - Please Help!
I am developing my first VSTO Outlook 2007 add-in and I have hit some problems. I would be very grateful if somebody could provide me with some helpful answers as I've been wrestling with this for ages. The ultimate goal of my add-in is to extend the Outlook 2007 UI by presenting my customers with a range of additional forms that meet their particular business needs. These forms will use a local database to store their information. So far I am concentrating on just one form called "Clients", and I have taken the following steps: 1. I have opened a Contacts form and created a Clients form region from it, implementing the 'replaceAll' formRegionType. 2. I have created an additional MAPIFolder called "Clients" wit ...Show All
SQL Server Running Database Diagrams Designer
New user here. I am following a step-by-step tutorial for Visual Studio 2005 and am in the process of creating the database. I have created the tables, and the instructions now recommend that I use the Database Diagrams tool to define the relationships. The instructions read "In the Server Explorer, right click the Database Diagrams folder and select Add New Diagram." But my Server Explorer does not display a Database Diagrams folder under my new database. Trying to follow recommendations on various Help screens, I have launched SQL Server Management Studio 2005 and connected to my database there. Here, a Database Diagrams folder appears -- but when I right click, there is no "Add New Diagram" option; the only choices are ...Show All
Visual C# Custom toolbars lost
Every time I create or edit a toolbar in VS2005 Pro, the changes are lost between sessions. Any new toolbar is gone; any modifications to the standard toolbars are also lost. I reckon you are right about the 3rd party controls. I have the same problem, I installed CoreLabs MySQLDirect and the problem started happening. I then uninstalled MySQLDirect and the problem went away. But does someone have a solution ...Show All
Visual C++ Functions as template arguments
I have the following code: typedef void* STACK; template <typename T, void (*S)(T* ptr)> class AutoPtr { public: int junk; }; template <typename T, void (*S)(T* ptr)> void FreeStack(STACK* stack) { // loop through all stack items and call S on each item } template <typename T, void (*S)(T* ptr)> class AutoStack : public AutoPtr<STACK, FreeStack<T,S> > { public: int junk; }; typedef void* RESOURCE; void FreeRESOURCE(RESOURCE* res) { // free the RESOURCE } int main() { AutoStack<RESOURCE, FreeRESOURCE> a; a.junk = 0; } Basically, I pass various free functions through the template. When I compile I receive: error C2440: 'specialization' : cannot convert from 'void (__cdecl *)(STACK *)' to 'vo ...Show All
SQL Server Conditional Where using a Parameter
How do I construct a select with a conditional where: If DefaultWH is not blank I want to add a "AND part". SELECT DISTINCT Name FROM Warehouse WHERE (Cono = @Company) CASE WHEN @DefaultWH' <> ' ' THEN AND (@DefaultWH = whseid) END Neith of the examples worked. I need to have the query run in 1 of 2 formats Parameter 1 = select company Parameter 2 = select DefaultWH Parameter 3 = SELECT DISTINCT Name FROM Warehouse WHERE (Cono = @Company) < === from Parameter 1 or SELECT DISTINCT Name FROM Warehouse WHERE (Cono = @Company) AND (@DefaultWH = whseid) <===From Parameter 1 and 2 I need to be able to drop or include ...Show All
Game Technologies: DirectX, XNA, XACT, etc. Im new and im interested in making a game!
Ok im new but I DONT KNOW HOW TO CREATE A GAME! can someone help me please! :) The best option for you is to start by having a search through the XNA Game Studio Express Forums on this site. Form there you will see lots of examples and tutorial sites that will help to get you started. I have put together a small Tutorial on the main Base application for XNA ( Your First Game ), you might want to have a look at that, other then that there are heaps of other sites around that will help. www.virtualrealm.com.au (My Site and Blog) www.xnadevelopment.com (Ran by George Clingerman) http://msdn.com/xna Microsofts XNA Development Center www.xnaresources.com www.xbox360homebrew.com Plus ...Show All
Visual Studio 2008 (Pre-release) Bind Image to single xmlelement
I'd like to bind an Image's datasource to a single element in an XmlDataProvider. Each element in the Xml has a unique ID and the image knows the ID it needs to bind to. Is there a way to set the binding of my image so it searches for the appropriate element Brian Here are the controls from Window down to the CaptionImage: Window->DockPanel->ScrollViewer->Grid->ViewBox->Canvas->CaptionImage ...Show All
Windows Forms onlick event for rectangle
Hello, I am drawing on a windows form using System.Drawing.Graphics. I would like to wire up specific regions/rectangles of the drawing to an onclick event. Does anybody know how to do this Thanks in advance for you help! RC I was able to figure out how to get the point in the form where the mouse clicks. Used the following code... private void split_Panel2_Click(object sender, MouseEventArgs e) { Point clickPnt = new Point(); clickPnt = e.Location; } Thanks for helping! RC ...Show All
Visual Basic Help: WebBrowser Control with custom http headers
I use WebBrowser control in VB.NET windows application and have to customise the USER-AGENT for only control under the application itself (does not effect the original IE) sample: Original USER-AGENT : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) desired USER-AGENT : My Application Name (any version) I saw that it is an overloaded function to add a custom http header but it is available only for POST method It is very easy to do this with VB6 but .NET is different. Tried searching over the internet but found no answer yet. I recommend iMacros from http://www.iopus.com/imacros It is basically a wrapper around the IE browser ...Show All
