|
Well, just for grins, try using integrated security instead of a sql identity. I doubt it will make a difference. The connection string would look like this: Server=(local);Database=Northwind;Integrated Security=SSPI
|
|
|
|
|
After reading some other forums on this, there are other people complaining about the exact same thing and the typical response is to increase the timeout. You could set it to something obscene like 5 minutes and see if it eventually connects. I suspect it's not the network, so maybe you could try an OLE or ODBC connection to see if anything is working at all.
|
|
|
|
|
That actually worked. Thanks.
The odd thing is that it seems to connect in less than 30 seconds, which was the old timeout value. I set the timeout to 600 seconds. After the first connection, it connects immediately. I guess I will need to connect to the database while the program is initializing to hide the long connect time from the user.
|
|
|
|
|
Weird. Well, I'm glad it works. I guess the good part is that you can open a connection in another thread while you're initializing and .Net will keep a connection pool open for you while your program's still open even if you close the SqlConnection.
|
|
|
|
|
Are you using SQL Server 2005? If so, I believe only the local protocols (named pipe, shared mem) are enabled by default (unlike SQL 2000 where TCP is enabled as well). You may have to enable the desired transport protocol (and possibly unblock it in your firewall) to connect remotely.
|
|
|
|
|
Hey ppl,
What's the best way to get an IntPtr representing my object?
The following works, but I don't know if that's the fashionable way to do it:
IntPtr pObject= Marshal.AllocHGlobal(Marshal.SizeOf(myObject));
Marshal.StructureToPtr(myObject, pObject, true); Also, AFAIK, the StructureToPtr() function copies the data to the new allocated memory, which consumes time.
Is there a better way?
Thanks in advance,
Shy.
|
|
|
|
|
Not by spamming the message bord, for sure.
---
b { font-weight: normal; }
|
|
|
|
|
lol... Sorry everyone...
I pushed the "Post Message" button, and got an error...
So I pushed it again, and again...
BTW... Is anybody else experiencing problem with the site except me (not like the one above)?
|
|
|
|
|
shyagam wrote: BTW... Is anybody else experiencing problem with the site except me (not like the one above)?
Yes that happens from time to time. Some days are worse than others.
shyagam wrote: Is there a better way?
Better how?
led mike
|
|
|
|
|
In my humble opinion there should be a way to simply get the address of an object, and store it as an IntPtr object...
|
|
|
|
|
shyagam wrote: there should be a way to simply get the address of an object
Yes it is in C++. Don't use a garbage collected platform if you want "simple" access to memory.
led mike
|
|
|
|
|
You could delete your redundant messages.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Absolutly right...
It's done!
I'm used to NOT being able to delete messages in other forums...
|
|
|
|
|
The people here are smart enough to answer a question if it's posted once. Personally, I never answer questions that have been posted several times. It's just a matter of principal.
|
|
|
|
|
Hello everyone!
I want to thank you all up front for any assistance you can provide--I am new, and it will become more obvious here in a second. =)
I am brand new to c# (and visual programming in general, I usually work on Linux) but for a project that I am working on I have the need to get video from a web cam and do image capture.
I have the video working (through directshow) and I am able to take pictures from my video box. Now for the real problem. Over the live video I need to either layer a transparent panel (with border) or draw a rectangle so that the user can decide what portion of the video they wish to capture for the still image. Eventually I will need to let them resize the capture block (keeping ratio) as well.
I hate to speak in generalities, but can anyone get me started please. This is part of an MDI, and thus far I cannot get any panel transparencies to work (they always show the color of the form behind the image, even when the video is the form background)
After a week of brick walls I am coming to the experts for direction--at least point me down the best path if you would..
Thanks for your time and assistance!!
Edwa5823
|
|
|
|
|
You could let the control draw a rectangle as the user selects area for stillimage, and then use the 'control to bitmap' function to capture that exact rectangle.
Bitmap _capturedImage = null;
Brush _redbrush = new SolidBrush(Color.Red);
Brush _blackbrush = new SolidBrush(Color.Black);
Pen _pen = new Pen(_blackbrush);
Point _mousedown = new Point(-1,-1);
Rectangle _captureRect = new Rectangle(_mousedown, 0, 0);
bool _mouseheld = false;
</p>
private void videopanel_MouseDown(object sender, MouseEventArgs e)
{
_mouseheld = true;
_mouseDown = e.Location;
}
</p>
private void videopanel_MouseMove(object sender, MouseEventArgs e)
{
if(_mouseheld)
{
videopanel.Refresh();
Graphics g = videopanel.CreateGraphics();
Point _mousemove = e.Location;
g.DrawRectangle(
_pen,
_mouseDown.X,
_mouseDown.Y,
_mousemove.X - _mouseDown.X,
_mousemove.Y - _mouseDown.Y);
}
}
</p>
private void videopanel_MouseUp(object sender, MouseEventArgs e)
{
_mouseheld = false;
Graphics g = videopanel.CreateGraphics();
Point _mouseup = e.Location;
_captureRect = new Rectangle(
_mousedown,
_mouseup .X - _mouseDown.X,
_mouseup .Y - _mouseDown.Y);
_pen = new Pen(_redbrush);
g.DrawRectangle(_pen, _captureRect);
}
</p>
private void CaptureButton_Click(object sender, EventArgs e)
{
Graphics g = videopanel.CreateGraphics();
Bitmap _bitmapComplete = new Bitmap(videopanel.Width, videopanel.Height);
Rectangle _bitmapRect = new Rectangle(
0,
0,
videopanel.Width,
videopanel.Height);
videopanel.DrawToBitmap(_capturedImage, _bitmapRect);
_capturedImage = new Bitmap(
_captureRect.Width,
_captureRect.Height,
g);
g.DrawImage(_bitmapComplete, _bitmapRect,
_captureRect, GraphicsUnit.Pixel);
}
NB!
Untested code though. Just something that popped into my head. Might have to refresh between each call to MouseMove to avoid multiple rectangles for instance.
Hope it might be of some help.
-Larantz-
-- modified at 18:56 Friday 27th October, 2006
Forgot to only draw while moving if mousebutton is held
Tested it now on .net 1.1. The storing and drawing of rectangle works like a charm, though I don't have 2.0 for Control.DrawToBitmap() method.
|
|
|
|
|
If you want the selected rectangle to draw in all four quadrants from start of selection, you can rewrite the MouseMove and MouseUp eventhandlers as follows:
private Point _rectstart = new Point(-1,-1);
private Point _rectend = new Point(-1,-1);
</p>
private void videopanel_MouseMove(object sender, MouseEventArgs e)
{
if(mouse_down)
{
videopanel.Refresh();
_pen = new Pen(this._blackbrush);
Graphics g = this.videopanel.CreateGraphics();
Point _mousemove = new Point(e.X, e.Y);
if(_mousemove.X > _mousedown.X &&
_mousemove.Y > _mousedown.Y)
{
_rectstart = new Point(
_mousedown.X,
_mousedown.Y);
_rectend = new Point(
_mousemove.X,
_mousemove.Y);
}
else if(_mousemove.X < _mousedown.X &&
_mousemove.Y < _mousedown.Y)
{
_rectstart = new Point(
_mousemove.X,
_mousemove.Y);
_rectend = new Point(
_mousedown.X,
_mousedown.Y);
}
else if(_mousemove.X > _mousedown.X &&
_mousemove.Y < _mousedown.Y)
{
_rectstart = new Point(
_mousedown.X,
_mousemove.Y);
_rectend = new Point(
_mousemove.X,
_mousedown.Y);
}
else
{
_rectstart = new Point(
_mousemove.X,
_mousedown.Y);
_rectend = new Point(
_mousedown.X,
_mousemove.Y);
}
_captureRect = new Rectangle(
_rectstart,
new Size(
_rectend.X - _rectstart.X,
_rectend.Y - _rectstart.Y));
g.DrawRectangle(
_pen,
_captureRect);
}
}
</p>
private void videopanel_MouseUp(object sender, MouseEventArgs e)
{
mouse_down = false;
Graphics g = this.videopanel.CreateGraphics();
_pen = new Pen(_redbrush);
g.DrawRectangle(_pen, _captureRect);
}
-Larantz-
|
|
|
|
|
In my app, there are labels and rich text boxes on a report. When I select Japanese, Korean, or Chinese locales, the text in the labels is displayed as Asian characters. But, the rich text box contains question marks (I'm running XP, SP2, US). Is there a way to display Asian characters in a rich text box on this operating system, or do I need a Chinese operating system, a Japanese operating system, and a Korean operating system to view the Asian characters in a Rich Text Box?
This code works for languages like German, Italian, French.
m_rtfCircuitDesc.Rtf = @"{\rtf1\ansi \nowwrap " + strDesc + "}";
Thanks in advance.
-- modified at 15:09 Friday 27th October, 2006
|
|
|
|
|
Does anyone see what's wrong with the following code?
I followed some earlier advice and simplified things greatly. I no longer get exceptions thrown but my secondStrucure has no no calculated data in it when my bigStructureObj is returned. In my testApp, I populate the bigStructureObj with all the data the VB6 program sends to the dll (This problem is not occuring in VB6.)
I have the following dll code / c# code. I am definitely new to this and am guessing I'm just not getting the reading I've been doing.
#define theSIZE 145
typedef struct {
float smooth[theSIZE];
float first_der[theSIZE];
float sec_der[theSIZE];
float integral[theSIZE];
} thirdStructure;
typedef struct {
long num_v_points;
float v_time[theSIZE];
thirdStructure results;
} secondStrucure;
typedef struct
{
long window;
long num_points;
float xdata[theSIZE];
float ydata[theSIZE];
float v_time;
secondStrucure rdata;
float integral_const;
float integral_time;
float desired_x; .
} bigStructureObj;
//******************************************************************************
[StructLayout(LayoutKind.Sequential)]
internal struct thirdStructure
{
[MarshalAs(UnmanagedType.SafeArray)]
internal float[] fSmooth;
[MarshalAs(UnmanagedType.SafeArray)]
internal float[] fFirstDer;
[MarshalAs(UnmanagedType.SafeArray)]
internal float[] fSecondDer;
[MarshalAs(UnmanagedType.SafeArray)]
internal float[] fIntegral;
public thirdStructure(int c)
{
this.fSmooth = new float[c];
this.fFirstDer = new float[c];
this.fSecondDer = new float[c];
this.fIntegral = new float[c];
}
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct secondStrucure
{
[MarshalAs(UnmanagedType.I4)]
internal int NumVirtualPoints;
[MarshalAs(UnmanagedType.SafeArray)]
internal float[] fv_time;
[MarshalAs(UnmanagedType.Struct)]
internal thirdStructure vb_Results;
public secondStrucure(int b)
{
this.NumVirtualPoints = 0;
this.fv_time = new float[b];
this.vb_Results = new thirdStructure(b);
}
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
internal struct bigStructureObj
{
[MarshalAs(UnmanagedType.I8)]
internal long iWindowSize;
[MarshalAs(UnmanagedType.I8)]
internal long iNumRealPoints;
[MarshalAs(UnmanagedType.SafeArray)]
internal float[] fRealTimePoints;
[MarshalAs(UnmanagedType.SafeArray)]
internal float[] fRealPoints;
[MarshalAs(UnmanagedType.R4)]
internal float fVirtualTimeWidth;
[MarshalAs(UnmanagedType.Struct)]
internal vb_LOESS_II_RESULTS vb_well_data;
[MarshalAs(UnmanagedType.R4)]
internal float fIntegralConst;
[MarshalAs(UnmanagedType.R4)]
internal float fIntegralTime;
[MarshalAs(UnmanagedType.R4)]
internal float fDesired_x;
public bigStructureObj(int a)
{
this.iWindowSize = 0;
this.iNumRealPoints = 0;
this.fRealTimePoints = new float[a];
this.fRealPoints = new float[a];
this.fVirtualTimeWidth = 0;
this.vb_well_data = new secondStrucure(a);
this.fIntegralConst = 0;
this.fIntegralTime = 0;
this.fDesired_x = 0;
}
}
|
|
|
|
|
|
What exactly you want to do?
"My advice to you is to get married. If you find a good wife, you will be happy; if not, you will become a philosopher." Socrates
|
|
|
|
|
|
What code have you written so far? No-one will do this for you. Show your efforts so far and when you get stuck people will offer help.
Kevin
|
|
|
|
|
|
|