|
Don't change the table structure?
No mapping tool is going to automatically fix your code if you significantly change the database design. I'd suggest you consider designing your database first, then coding.
|
|
|
|
|
Hello sir,
Thanks for your reply.
As you would realize that, in future, I may need to add an extra field in a table or I may need to delete a field from a table. I think, the nature of this requirement is common to every developers, not only me. So, what is the efficient procedure to handle this situation in the future ?
One benefit of using DataSet that I was enjoying... When I changed a field in my database, I updated the dataset and as all table adapter methods stay together in the datase, I can easily track the usage of the methods in my code and fix accordingly. But when I am using DBML file, I dont see any methods (unless SPROC) in the DBML file, so I wont have any idea about how many files are using the table from the DBML. Thats why, I was wondering and thinking that, there must be a way.
|
|
|
|
|
hello,
I'm testing .NET connection pooling facility, I configured max pool size 10 and in accordance there was no exception when I oConn.Open until I opened the 11th connection.
<br />
static void Main()<br />
{<br />
string strConn = "Data Source=DEV\\SQLEXPRESS;Initial Catalog=Northwind;Persist Security Info=True;User ID=NorthwindSA;Password=xxxxx;connection reset=false;connection lifetime=5;min pool size=5;max pool size=10";<br />
<br />
IDbConnection oConn = null;<br />
ArrayList oConnections = new ArrayList();<br />
int nIndex = 0;<br />
<br />
for (int i = 0; i < 20; i++)<br />
{<br />
try<br />
{<br />
oConn = new SqlConnection(strConn);<br />
oConn.Open();<br />
oConnections.Add(oConn);<br />
<br />
Thread.Sleep(100);<br />
}<br />
catch (Exception ex)<br />
{<br />
Console.WriteLine("iteration: " + i + ", " + ex.Message);<br />
nIndex = i;<br />
break;<br />
}<br />
finally<br />
{<br />
<br />
}<br />
}<br />
<br />
Console.WriteLine("max number connection established: " + nIndex + ", preparing to dispose connections openned");<br />
<br />
foreach (IDbConnection oConn2 in oConnections)<br />
{<br />
if (oConn2 != null)<br />
{<br />
try<br />
{<br />
oConn2.Close();<br />
}<br />
finally { }<br />
}<br />
}<br />
oConnections.Clear();<br />
<br />
return;<br />
}<br />
However - one thing I am not sure is - I'm watching Perfmon \ SQL Server General Statistics \ User Connections. The counter is showing "3" before and after test. The fact that my test application fires up 10 new connections (min=5,max=10) does not seems to have anything to do with Perfmon counter.
Thanks
dev
|
|
|
|
|
Trying doing a query with each of the connections as see what happens.
Also, the PerfMon counter you're using is looking at the connections inside SQL Server. It's not looking at them from your code's point of view.
You might find it interesting to look at both sides at the same time. Start looking at the .NET Data Provider for SQL Server counters.
|
|
|
|
|
I am trying to correlate oConn.Open with Perfmon counter...
dev
|
|
|
|
|
And ....?? My answer doesn't change.
|
|
|
|
|
I think it nonsense if some application can access parallel port without additional driver
but I must provide own driver. After attach an "dll viewer" to "portmon", I found exported function
called _inp and _outp inside msvcrt.dll or msvcr80.dll. It looks like same with _inp and _outp
function on turbo c++ compiler. When I try to call with
[DllImport("msvcrt.dll",EntryPoint = "_outp")]
public static void OutP(int address, int value);
there's no exception occurs, but my application always shutted down with errors.
Is someone there know what signature of "_outp" is? or know whats wrong with my program?
(my program just have two textboxes to input address and value and one button to execute)
No one can prevent me to learn something
|
|
|
|
|
hello
This article[^] tells me it's possible thread aborted before created file is assigned to variable "w" by looking at IL - I examined IL but not sure how we can arrive at that conclusion:
<br />
Aborting pure .NET code is less problematic, as long as try/finally blocks or using statements are incorporated to ensure proper cleanup takes place should a ThreadAbortException be thrown. However, even then, one can still be vulnerable to nasty surprises. For example, consider the following:<br />
<br />
using (StreamWriter w = File.CreateText ("myfile.txt"))<br />
<br />
w.Write ("Abort-Safe?");<br />
<br />
C#'s using statement is simply a syntactic shortcut, which in this case expands to the following:<br />
<br />
StreamWriter w;<br />
<br />
w = File.CreateText ("myfile.txt");<br />
<br />
try { w.Write ("Abort-Safe"); }<br />
<br />
finally { w.Dispose(); } <br />
<br />
It's possible for an Abort to fire after the StreamWriter is created, but before the try block begins. In fact, by digging into the IL, one can see that it's also possible for it to fire in between the StreamWriter being created and assigned to w:<br />
<br />
IL_0001: ldstr "myfile.txt"<br />
<br />
IL_0006: call class [mscorlib]System.IO.StreamWriter<br />
<br />
[mscorlib]System.IO.File::CreateText(string)<br />
<br />
IL_000b: stloc.0<br />
<br />
.try<br />
<br />
{<br />
<br />
...<br />
<br />
Either way, the Dispose method in the finally block is circumvented, resulting in an abandoned open file handle – preventing any subsequent attempts to create myfile.txt until the application domain ends.<br />
I can't see where in IL the variable "w" get assigned the created file stream writer.
devy
|
|
|
|
|
Here:
IL_000b: stloc.0
The reference to the stream writer is the return value of the call on the previous line, so that is what's in the accumulator.
The variable w is the first variable in the method, so that is allocated at position 0 in the stack frame.
The instruction stloc.0 stores the value of the accumulator at location 0.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks
Sounds like to understand this I need to know assembly and IL ...
devy
|
|
|
|
|
Not at all. You only have to realise that calling a method and assigning the result to a variable are two separate operations, so the thread can be aborted between those operations.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
thanks
think i understand that - that create file stream and assigning it to variable "w" is not atomic and is indeed two-step operation.
But I wish I could read assembly and IL so I can ildasm then check on things myself.
devy
|
|
|
|
|
hi
how can i send bit's to usb in c# ?
thank's
|
|
|
|
|
There's nothing built in to C# to support this, you'd need to find a library you can consume to do that.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
can i get some direction ? i dont know from where to start ?
|
|
|
|
|
|
Hi,
years ago, when PC interfaces where just serial port and parallel port, it made sense to talk to the port, and make it send and receive the bits and bytes the peripheral manual told you to send and receive in order to operate some peripheral.
Nowadays you should focus on the peripheral device, and not on the interface or cable that is used. So your program should not address the USB bus, it should address the PC driver that goes with the peripheral. A commercial peripheral comes with such a driver; also microcontrollers and other electronics typically come with the drivers required to connect them to a PC. If your vendor cannot offer a driver, you have two choices: change product and vendor, or start developing your own driver (a major effort).
BTW: if your USB is used as an intermediate interface, the same applies. So USB-to-serial cables,
USB-to-parallel cables, USB-to-Ethernet cables, all have their own drivers, and you can forget the USB aspect of them alltogether: the serial port/parallel port/Ethernet will behave almost like its twin on the motherboard. And Vista has most of these drivers built-in too.
|
|
|
|
|
A very good and solid answer!
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Hey.
I'm currently hijacking the WM_NCCALCSIZE function to define a custom caption and border areas.
But i'm having an issue with the form constantly resizing itself.
When I maximise the form, it fills the screen like I want it to, but when I restore it back, it's height and width properties are decreased.
I know where in the code it's happening, but I don't know how to stop it from constantly reducing in size, but rather maintain it's original size and simply "append" the non-client area. Any help would be appreciated
Here's the function for the WM_NCCALCSIZE calculations:
protected void WndNCCalcSize(ref Message m)
{
NativeMethods.NCCALCSIZE_PARAMS para = new NativeMethods.NCCALCSIZE_PARAMS();
NativeMethods.RECT winRect;
if (m.WParam == IntPtr.Zero)
winRect = (NativeMethods.RECT)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.RECT));
else
{
para = (NativeMethods.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.NCCALCSIZE_PARAMS));
winRect = para.rgrc0;
}
IntPtr HDC = NativeMethods.GetWindowDC(this.Handle);
winRect.Top = winRect.Top + CaptionHeight;
winRect.Bottom = winRect.Bottom - 3;
winRect.Left = winRect.Left + 2;
winRect.Right = winRect.Right - 2;
this.BRect = winRect;
if (m.WParam == IntPtr.Zero)
Marshal.StructureToPtr(winRect, m.LParam, false);
else
{
para.rgrc0 = winRect;
Marshal.StructureToPtr(para, m.LParam, false);
}
NativeMethods.ReleaseDC(this.Handle, HDC);
m.Result = new IntPtr(NativeMethods.WVR_REDRAW);
base.WndProc(ref m);
}
Thanks.
|
|
|
|
|
Hello,
I have a richtextbox richTextBox1, and all I want to do is prevent the tab key from actually inserting a tab in the richTextBox1. instead I am catching when the tab key is pressed, and switching to the next control in my form, which I have been able to successfully do. How do I do this, I have tried using e.handled = true for the keydown and keyup events, to no success.
thanks!
Stephen
|
|
|
|
|
Hi,
First, set the AcceptsTab property of your richtextbox to true to ensure that keydown is raised on the tab key.
Then, you need to set
e.SuppressKeyPress = true
instead of e.handled.
|
|
|
|
|
Dear all,
I have one c# window form which contains datagridview controls,i have made
some columns visibility to fale.I have one button control when i click the
button another form opens and when i will close the second form i need to
show main form datagrid view control columns by seeting visible=true.
This is happing fine but the datagrid view is not refreshing.I tried with
datagridview.refresh() method also.
Please help me on this.
Regards
Veeresh
i want to join this group
|
|
|
|
|
Hello,
I have a listview in largeicon mode. If I press the right arrow when the rightmost item is selected in a row, nothing happens. I would like it to jump to the first item of the next row.
What I tried was cancelling the keydown event for he left and right arrows, and handling the selection manually (and calling ensurevisible()).
The problem with this is that I want to do some processing for the newly selected item.
My method will raise the selectionchanged events for every single item I visited. The default method only raised it when we 'settled' on an item (and sometimes in betwen )
If I keep the down arrow pressed, items will keep getting selected, and the listview will keep scrolling. This is good.
If I keep the right arrow pressed, I will keep processing all of them, which delays EnsureVisible(). This means that the selected item will be off screen for most of the time.
Any ideas?
|
|
|
|
|
Hello, I want to do packet filter program and I've found some articles about packet sniffing but I've a problem. I'm trying to create raw socket but I always get socket exception with error code 10013 (access denied). I''m using Windows Vista and VS 2008 Express.
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Unspecified);
I try to run this code on VS 2005 and it was fine...no exception. So I don't know where the problem is.Anyway, any suggestions how to do packet filter in C# or how to block ports or internet acess(for specified program or for all)? Thanks.
|
|
|
|
|
Member 4680844 wrote: I''m using Windows Vista and VS 2008 Express.
Yeah, RAW packets are off-limits to all user accounts. THe only account that can create RAW packets only under an Administrator account. It's been that way since SP2 came out for Windows XP.
Member 4680844 wrote: I try to run this code on VS 2005 and it was fine...no exception.
Speaking of XP, was this code under 2005 perhaps running under Windows XP or XP SP1?? Under XP and XP SP1, normal user accounts could create RAW packets without any issues. The same code, running under the same account, will not work under XP SP2 and above.
|
|
|
|
|