|
I assume that you expect an error because the record already exists? Then do it the other way arond; first try the update and check how many records were updated. If the record didn't exist the number of records is zero, and you know that you have to make an insert instead.
If you are using MS SQL Server, you can do this in a stored procedure:
create procedure DoSomeSetting
@SomeId int,
@SomeValue somedatatype
as
update DaTable
set Something = @SomeValue
where SomeId = @SomeId
if @@rowcount = 0 begin
insert into DaTable (Something)
values (@SomeValue)
end
---
b { font-weight: normal; }
|
|
|
|
|
hi
i have this code in VB and i want to Convert this code to C# but i don't know VB. Please Convert this code
To C# :
Dim nextLine As Int32
Call PrintGridHeaderLine(e)
Dim StartOfpage As Integer = _CurrentPrintGridLine
For nextLine = _CurrentPrintGridLine To Min((_CurrentPrintGridLine + RowsPerPage(_PrintFont,
e.Graphics)), CType(_DataGrid.DataSource, System.Data.DataTable).DefaultView.Count)
Call PrintGridLine(e, nextLine)
Next
Thanks ..
|
|
|
|
|
Int32 nextLine;
PrintGridHeaderLine(e);
int StartOfpage = _CurrentPrintGridLine;
for (int nextLine = _CurrentPrintGridLine; nextLine <= Min((_CurrentPrintGridLine + RowsPerPage(_PrintFont, e.Graphics)), ((System.Data.DataTable)(_DataGrid.DataSource)).DefaultView.Count); nextLine++) {
PrintGridLine(e, nextLine);
}
Aashutosh kumar
|
|
|
|
|
Hi,
I send mail thru C# code. During execution it throws
following error.
Unhandled Exception: System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.
at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 of
fset, Int32 read, Boolean readLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
at System.Net.Mail.SmtpReplyReader.ReadLine()
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at Sendmail.Main()
You only have to do a very few things right in your life so long as you don't do too many things wrong.
Vivek.S
|
|
|
|
|
IIS is installed in your PC or not. I think ,System.Net.Mail.SmtpClient.Send user virtual SMTP if you not specify Explicitly .
Check Virtual SMTP under IIS is running or not.If not then run Virtual SMTP.
Then you can send mail successfully.
Regards
rajesh
|
|
|
|
|
Wen is setted to = none you cant move it it all..
i wanna do like msn have..no matter where you click[except if its a component] the form can be moved
anyone knows?
|
|
|
|
|
set enable drag to true
create a variable in form class
bool draging
on mouse down event do
draging = true
on mouse up event do
draging = false
on mouse move event do
if(draging )
get mouse position every time save it to point vriable
check current postion with previous one
if they are not equal
change
this.position.x-=(point.x-e.mouseposition.x);
this.position.y-=(point.y-e.mouseposition.y);
and you are done
the above name of properties meathod may vary from actuals
i dont have c# ide this time
|
|
|
|
|
Amar Chaudhary wrote: i dont have c# ide this time
It's the logic that counts
|
|
|
|
|
I can't seem to figure out a way to loop over all cells in a DataGridViewColumn from within the column itself.
I have a class which extends the DataGridViewColumn class, and from within it I need to check all cell values in a way similar to:
foreach(DataGridViewCell cell in this.Cells){
// evaluate cell contents
}
Is there any property of the column I can use to achieve this? This functionality seems to be lacking from the column classes, though implemented in the row classes.
|
|
|
|
|
Hi all !
How can i access a specified field in 'Crystal Report'
eg: like how can i increase a value of a specified field of
'Crysatl Report'
Thanks bye
SalehMahmoud
|
|
|
|
|
Can anyone tell me where I can download OpenSource application that has been developed with modules?
Or a book to download with that topic - how to develop module oriented applications?
Thanks.
|
|
|
|
|
Just break your app into DLLs, surely ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
And this is it? Just break into dlls?
Then, this is something like plugins?
But, what if I want to store in Xml file which module have to be placed in panel control?
I want to have a module oriented application, but I want to enable to place a modules on forms by specifying its position in Xml file, like:
<root>
<Module Name="UsersList" Position="LeftPane" />
<Module Name="Diagram" Position="LeftPane" />
<Module Name="ManageUsers" Position="MiddlePane" />
</root>
So when program loads, he (program) decides where to place a module (in which pane) based on informations in Xml file.
I know that I have to create a new instance of UserControl and then to place it in Panel, but how can I do this in a loop when I specify the name of the module (from xml)?
In ASP.NET I will do this like so:
Control c = this.LoadControl("control path");
c.ID = "blah, blah";
PlaceHolder.Controls.Add(c);
I want the same functionalaty in Win Forms.
Thats why I've asked about OpenSource program or a book with this topic, to see how can I achieve this.
I hope you understand what I want.
Thanks.
|
|
|
|
|
You are trying to dynamically load assemblies and instantiate types. This[^] article should give you a start. You'll primarily be using reflection to instantiate types from strings in the XML file.
|
|
|
|
|
Thank you. This article will help.
So module oriented application is done like plugins or this is another way to achieve a module oriented application?
|
|
|
|
|
My apologies if this has been covered earlier or elsewhere - I did look but couldn't find anything.
I'm coding an app in C# using VS 2005 and I'm looking to make the interface as Vista-like as possible. Clearly, things like the control boxes on forms will be handled by the the OS - but what about buttons and the green-glow progress bar (to name a few)?
Are there libs I can download from MS to build into my app to get these "Vista effects"?
Is there something simple that I'm overlooking?
Any help is much appreciated.
Kind regards,
John.
|
|
|
|
|
Glowing buttons are progress bar are also handled by the OS. If your controls use XP style on XP, they should also look fine on Vista.
|
|
|
|
|
|
Please help me to create this frame message on ASP.NET and window application
thank you.
Message type....
Subject.....
Text
..............
...............
...............
Please reply me ASAP to my email: saigonxuanay@yahoo.com.sg
ngh
|
|
|
|
|
I am loading a form from an XML. I store the location and size info as follows:
<window number="1" x="110" y="145" width="700" height="722">
But each time I load the form, it's height is exactly 20 pixels smaller than what is in the file.
Not to mention the form I launch from shows a 20 point shrinkage as well even though visually it does not chage size.
The code I use to launch the window is:
Window win = new Window(this, name, nextCollWinXMLNode);
win.Show();
Has ayone experienced this behavior before?
Thanks,
RABB17
RABB17
"Nothing fancy needed, please just solve all our problems as quickly as possible."
|
|
|
|
|
it is dependent on the height of the title bar which in default xp theme is 20 pixels
size of title bar may variate with change in os and / or theme
toget rid of this experiment with position and size variable
i did that few weeks ago but i didnt remember what actualy was the solution
|
|
|
|
|
Is there a way to make it universal across OS/Theme? In other words, is there a way to get the size of the title bar and or border?
RABB17
"Nothing fancy needed, please just solve all our problems as quickly as possible."
|
|
|
|
|
sorry for late responding
<br />
int diff = 0;<br />
diff = this.Height - this .ClientRectangle.Height;<br />
diff = this.Height - this.DisplayRectangle.Height;<br />
<br />
|
|
|
|
|
Is there a way to make it universal across OS/Theme? In other words, is there a way to get the size of the title bar and or border?
Thanks,
RABB17
RABB17
"Nothing fancy needed, please just solve all our problems as quickly as possible."
|
|
|
|
|
Thanks,
I figured this out. I was passing my form and initialized the sizer after it had already been initialized once. Now I just set a global variable and set it on the passed form.
RABB17
RABB17
"Nothing fancy needed, please just solve all our problems as quickly as possible."
|
|
|
|