Although you can return a value from a call to ExecuteNonQuery, its slightly harder to setup as you must use output or return parameters from your query.
If you want to return a single value (say a 1 or 0 to indicate success/failure), you may find it easier to use ExecuteScalar. However, this returns a type called object which you must cast to an int (if that is what is being returned from the query)
Now, it is not clear from your code what t1 was supposed to return, but the sensible thing would be to return the new key from the table row just inserted. You could return 0 if the insert did not succeed and the rest of your code should then work fine.
I think @@IDENTITY works for Access for returning a newly inserted key, so your statement should change to:
I call the "GetOpenFileName" (Win32 API function) to creates and Open a dialog box. The dialog box is popped up but it is a modeless dialog. What I want is a modal dialog box. Anyone know how to solve this problem? Thanks.
-- modified at 5:35 Wednesday 29th August, 2007
I have to customise the OpenFileDialog so that it support the picture preview in the OpenFileDialog box. So I can't use the normal OpenFileDialog class.
I have cretated one Class Library using C# and i have done tlbexp<dll> and red asm<dll>.
I wrote Client Application using win32 Console application by importing tlb.
but when Iam trying to do the CreateInstance it is giving "Class Not Registered".. Can ypu give me the Solution for this.
Hi dears, i have problem regarding spliting and parsing Data from TextFile.. i want to store that data into the database.
my file look like this.
Product Specs :
Ambient Temperature: ||-40ï¿½ to +40ï¿½C
Connector: ||N, BNC, TNC, 7/16
Coolant: ||Dry (Convection cooled)
Finish: ||Silver ot Tri-alloy plated
Frequency Range and VSWR: ||DC to 1 GHz at 1.10:1 max, 1 GHz to 6 GHz at 1.25:1 max. (N type), 1 GHz at 4 GHz at 1.25:1 max. (BNC and TNC)
Nominal Size |(with Male N-type connector): 1.6" L x 0.8" Dia.,(40.7 mm x 20.4 mm)
Operating Position: ||Any
Power Rating: ||2 Watts
Weight: ||1.9 oz. (55 g)
"||" is a delimeter before this delimeter there is value like weight i want all these into a sperate AraryList and After the Delimiter i need to store all the data to the coresponding index of the first Arraylist...
Any help would be Appericiated.
I am having list box on form filled with some items. I want to close the form on the double click on any of List items.
I am able to handle double click event but that is of ListBox control not of the item. So once the item is selected and somewhere else(not on item) user double clicks unintentionally then also it gives me selection.
Is there way i can hanldle the event only for double click on listBox items?
I have a very dirty workaround for you. Some, might say I only provide dirty solutions
Easy solution would be to use the MouseDown event and chack the Clicks property of the MouseEventArgs.
I know that "Clicks>1" is not equal doubleclick, but maybe it fits for you.
Here you can do a check if the Y position of the MouseEventArgs is inside a region.
This region can be validated with the "PreferredHeight" property of the ArrayList class.
Dirty is, that it needs an offset depending on the "BoarderStyle" you are using.
Here an example:
privatevoid yourListBoxes_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
//Not really DoubleClick, but maybe ok for youif(e.Clicks>1)
ListBox ActListBox = sender as ListBox;
if(ActListBox.BorderStyle == BorderStyle.None)
YactHeight= ActListBox.PreferredHeight - 8; //Offset needed
//Is inside Items region//Do stuff here
If you need it more often I would suggest you to inherit your ownb ListBox.
This should override the OnMouseDown method and do the validation there.
If the position is inside the Items region you could fire an custom event there, which you handle in your code.
The other solution could be, to handle the DoubleClick.
As the System.EventArgs do not provide a act position, you would have to use the Cursor position in combination with the controls position PointToScreen.
Is there a way that I can import multiple projects (csproj, vbproj) at one time. As we all know vs2005 has a add project to solution option, but I cannot select multiple projects at once. I have a lot of projects and importing one at a time get tedious very quickly. So if there is any plugin/app/workaround please let me know.
Last Visit: 31-Dec-99 18:00 Last Update: 23-Sep-23 14:56