Poetjevel's Q&A profile
Visual C# SQLExpress Smallint into C# : problem with ternary operator
Hi Everyone, I'm connecting to an SQLExpress database to retrieve some data, and am having some problems with retrieving int's. I can successfully retrieve standard length int's, but am unable to retrieve smallint's. I'm using the following code: cmd.CommandText = qry; // type DbCommand with input SELECT string DbDataReader reader = cmd.ExecuteReader(); if(reader.HasRows) { while(reader.Read()) { Int64 tkNo = reader.GetInt64(0); // works fine .. .. .. Int32 comp = reader.GetInt32(6); // error occurs // also tried the following // Int16 comp = reader.GetInt16(6); // int comp = reader.GetInt32(6); // Int64 comp = reader.GetInt64(6); } } The error is: Second System.InvalidCastException: Specified cast is not ...Show All
Visual Basic Order of menu items in MDI container.
The menu items of child forms in a MDI container merge with the menu items of the MDI form in a manner which is different from what is commonly used. This is because we now (in contrast with VB6) need at least one item from the MDI form to call a new child form, e.g. "New" or something like that. This item then comes before the items of the child form, where I do not want it. Can the order of the menu items after merging child and parent menus be changed I've worked with MDI childs and am not sure why you want your menu changed around...the main reason to use MDI children is to keep the parent menu and use it in other forms. But if you really want it changed I'd suggest module boolean variable ...Show All
Visual C# Using break with nested loops
Hey, trying to write a pretty simple piece of code, seeing if there's a bit more elegant way to do this in C#. I'm trying to write a nested for loop, and have a single break statement to break out of the highest for loop. For instance, in Java this would be done like this: outerloop: for (int i=0; i<10; i++) for (int j=0; j<10; j++) if (condition_met) break outerloop; Does C# have a similar method for defining a different loop to break out of than then innermost one TIA. -Stephen As far as I know, you'd have to use a goto: for ( int i=0; i<10; i++) { for ( int j=0; j<10; j++) { if (condition_met) goto outsideloop; } } outsideloop: This is of ...Show All
SQL Server Limit number of rows returned
I am developing a top 20 report. How do I limit the report to only return up to 20 rows (detail lines, no groups) Thanks Hello, Use Dyamic Queries like ="Select top " & Parameters!t.value & " pub_id,pub_name from dbo.publishers where city=ISnull(@City,City)" & order by & Parameters!col.Value To populate the Col Parameter where the user is going enter the sorting Column.Use the Query like this Select a.name from syscolumns a join sysobjects b on a.id=b.id and b.xtype='U' and b.name='WBHierarchy' --tablename I did not try ,Hope it will work Here i have given the top rows selection also as parameter Pls reply,if it is working. Thank you, Ra ...Show All
Visual C# which event has been raised
how can i know from inside a DoWork event handler " backgroundworker" that a specific button has been pressed dowork { if btn1_clicked execute procedure1 if btn2_clicked execute procedure2 } Usually the click of a button either cancels an executing BackgroundWorker process or starts a new one. Are you expecting to start a BackgroundWorker to sit and wait for button presses ...Show All
Visual Studio Team System Error in VS2005 on Get Latest command
After opening a solution that is bound to TFS in VS2005, I right click on the solution in solution explorer and select "Get Latest Version (Recursive)". An Error message is produced saying: Unexpected error encountered. It is recommended that you restart the application as soon as possible. Error: the specified procedure could not be found. File: vsee\internal\inc\vscomptr.inl Line number: 618 Jason, This looks like it could be related to a reported problem with setup/uninstall of oledb components. See the following threads to see if they help. http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=215771&SiteID=1 http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.asp ...Show All
Game Technologies: DirectX, XNA, XACT, etc. Timing in a C# Managed DirectX Game
Im currently programming a C# 2d Game Engine in Managed DirectX and I am having some problems with how to do timing. Ok for now I have a class set up for timing (copied from mdxutil.cs) which gives very accurate time. Now my problem is how to use this time. First I have a class called Sprite, with a method Update(double absoluteTime) and each frame I call this method and pass the current time from the timer. Now lets say I want to move the sprite (according to its velocity) 5 times per second, and I want to update the sprites animation every 2 times a second. How would I use the timer to accomplish this. Is my approach right or am I completely off track Thanks You're on the right track. Now you just nee ...Show All
SQL Server Creating full-text indexes on a table in a publication
I have a table that is in a one way transactional publication. I need to create a full-text catalog on this table and have that catalog exist on the subscriber as well. I understand simply creating a FTC for an object in a publication will not cause that FTC to be replicated to the subscribers. I have scripted out the command and tried to use sp_addscriptexec to push it to the subscriber. When I do this, I get the following error: Last 183 characters in 'sqlcmd' output buffer: Changed database context to 'database'. Msg 574, Level 16, State 1, Server SQLSERVER, Line 2 CREATE FULLTEXT CATALOG statement cannot be used inside a user transaction. Also, when this script is run directly from the subscriber, it works fine (but since the subscribe ...Show All
Smart Device Development Today screen wallpaper programatically(urgent help required)
Can any one help me in setting a wallpaper to a today screen programatically. I tried the following steps but could not succeed : edited the registry key HKEY_CURRENT_USER/ControlPanel/Desktop and in the wallpaper key i gave my own file name. and issued a sendmessage(); again i tried with HKEY_CURRENT_USER/Software/Microsoft/Today and added a file name under wall key. i used the wall key because when i tried to set the wallpaper using manually a wall key is getting created . can any one help me with this i need an urgent help.please help me. I don't need the sample code for writing a today screen plugin rather I want to write a program which can set an image as wallpaper for today screen. Could you pleas ...Show All
Visual Basic Enter Button for a Field
I read in another thread about this but I didnt get what was said...so ill reask this: I have a form. I want the form to activate a button after the user has typed some text and pressed enter. May I take issue with point 1. KeyPress can detect Enter, it is chrw(13). KeyUP/Down detect the actual pressing of the key and passes the keyboard code for the key pressed. KeyPress passes the ascii value of the character for the key pressed translated through the keyboard codepage, it will be upper or lower depending on the state of the shift key. If you want to detect special keys then UP/DOWN are better. Example I want to allow the user to terminate the application via keyboard using ESC, to make sure it is not accidental I want to make it S ...Show All
SQL Server datetime format
Hi. I have two parameters called StartDate and EndDate.These parameters are from datetime type. I want to view the records between these dates.I have some questions: 1)In the database, these parameters' values are like 15.11.1984 23:59:14. It has time value near the date value.But I don't want to view the time value.I only want the date part. 2)In the preview tab, I choose a date clicking the calendar image near the parameter textbox. For example I choose 02.05.2001 and when I click the view report button, it changes to 05.02.2001.So there is a format difference.I want it to show like dd.mm.yyyy 3)By default, if the user doesn't enter a date, I want to view all the records.Any idea about this Thanks! km ...Show All
Gadgets C# DLL
Hi, Is it possible to call methods stored inside a C# dll from a gadget If so please could someone show me an example of how to make the method call I have seen code for how to register/unregister the dll in the gadget code, but thats all i know. Thanks, Jason Hi peter What exactely are you trying to achieve I remember there was a class named PerformanceCounter in the .net Framework. You could simply create a .net component, make it Com Interoperable and then use the data from it in your gadget. If this is what you are looking for: I have created a small gadget (my first as well) the past nights. It should be done by tomorrow. It doesn't use the PerformanceCounter class but some other classes, but ...Show All
SQL Server AMO: Hanging on Partition.Update
I am using AMO to manage partitions. I am trying to create a partition then use the Update method to create the new partition.. snippet of code below: 65 //create the new partition 66 Partition newPartition = mg.Partitions.Add(partitionName, partitionName); 67 newPartition.StorageMode = StorageMode .Molap; 68 newPartition.Source = new Query ...Show All
Visual C# Mixed languages in Visual Studio
Can I use mixed languages in Visual Studio i.e. some source files in C# (.cs), others in C++ (.cpp) my code was just a simple example my friend! It was just a made up class and made up method demonstrating on how to call a class/method from a different language to a different language ...Show All
Visual Basic cant open .VB file in visual studio editor,opens in hex view bug?
Hello, I have a strange problem that I have looked for the answer to but no solution has seemed to work yet. I am using Visual Studio 2005 with Visual source safe, and I have a visual basic solution I am working with. For one of the .vb files in my soution (parser.vb), visual studio for some reason stopped opening the file. Yesterday everything was working fine like normal, but now, when I double click the file from the solution explorer, it will open the file in what looks like a hex editor in a new tab (this is all still within the visual studio IDE, it doesnt pop open a separate application or anything). All the other files in the solution still open normally with the vb code editor with intellisense and ...Show All
