|
running on Windows 2003 server
IDE is VS2008
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|
i mean that could be a bug what IDE you use ?
i got the same behaviour a couple time ago.. i think i solved it with a reinstallation of the IDE
hope i could help
|
|
|
|
|
I am using visual studio 2008 and runnin on windows 2003 server machine
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|
i got a check box column in my datagrid.
how should i code to fire check event
|
|
|
|
|
If you are placing your check box in a datatemplate, you could use something like -
<DataTemplate>
<CheckBox Checked="CheckBox_Checked"/>
</DataTemplate>
The check box checked event will then handle check box click.
A click event is also available.
|
|
|
|
|
Hi all,
Some background information:
I have a method A that calls another method B. In method B an asynchronous TCP/IP read occurs: this.tcpClient.GetStream().BeginRead(byteReadBuffer, 0, byteReadBuffer.Length, new AsyncCallback(ProcessReadBuffer), tcpClient.GetStream()); on result method ProcessReadBuffer
So my question:
How can I wait for the asynchronous ProcessReadBuffer method to complete in method B. Reason being that I require some results from ProcessReadBuffer method in method A?
Many thanks in advance.
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
Why not just call it synchronously then?
Regards,
Rob Philpott.
|
|
|
|
|
|
Try storing the result in an IAsyncResult variable and then call AsyncWaitHandle.WaitOne() on that object.
|
|
|
|
|
Hi,
Thanks for the response.
I did try doing that, but I noticed that the WaitOne() returns immediately with a true result and only then after it goes into the method.
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
Strange - this is how I used it -
ar = u.BeginInvoke(param, new AsyncCallback(Complete), "state");
ar.AsyncWaitHandle.WaitOne();
u was the my delegate and param was the parameter I passed into that method that my delegate invoked.
|
|
|
|
|
|
Hey, can anyone point me to tutorials about using the ReportViewer control in Visual Studio 2008? Also please only mention tutorials which are visual (have screenshots).
Thanks
|
|
|
|
|
|
Hi,
I want to connect to an ASP.NET Membership database from a command line as I need to list the user details.
The code I've come up with will connect to a named database easily enough but a membership database is local to an ASP.NET web site so I don't really know what to do. I can locate the MDF and log files easily enough but the database name can't be seen in Management Studio unless I attach to it and I need the database name to get the database owner so that I can then attach to the databse.
If I attach to it in Management Studio, the database name appears to be a large string including the absolute path, but there must be a way of deriving the database name from the MDF file itself, surely?
If I use the name I find in Management Studio I get an error message stating that I can't attach a database with the same name as an existing one! This is when the database is attached in Management Studio. I then detach it in Management Studio, run my code again and when it tries to get the database owner by specifying the database name in the Server.Databases list, I get an unreferenced object error. I'm completely confused!
So what I want to know is, how to I connect to a database using only its MDF file (and LDF file if necessary)?
Thanks
|
|
|
|
|
Server=.\SQLExpress;
AttachDbFilename=|DataDirectory|mydbfile.mdf;
Database=dbname;
Trusted_Connection=Yes; Source: http://connectionstrings.com/sql-server-2005[^]
The list of names in the Management-Studio are "aliases", short names that point to a file. If you attach a file, make sure to give it an non-existing alias. I usually try to deduce one based on the file-name.
You could use SMO to check what database-names are already in use
I are Troll
|
|
|
|
|
Thanks, I'll try that. I didn't realise that to attach a database I'd have to supply my own name.
The issue with that connection string you quote though, is that it specifies "DataDirectory" as though my application was a web-based one and that it had access to a local directory, "App_Data". I'm guessing then that I'll have to create a connection string which includes the full path of the MDF file and use that. It's then just about whether I can get the Membership object to reference the chosen database.
|
|
|
|
|
I am extracting 378000 BLOBS from a database.
This is mostly pdf,doc, and docx, but also some big wav,tiff,mpg, ++.
The code I'm currently using is a bit slow..
Does anyone have a tip on how to speed things up?
using (r2d2 = cmd.ExecuteReader(System.Data.CommandBehavior.SequentialAccess))
{
if (!r2d2.HasRows)
throw new Exception();
DirectoryInfo dir = new DirectoryInfo(Path.Combine(_arbeider.KonverteringsAlternativer.RootOutputDirectory, "DOKUMENT"));
if (!dir.Exists)
dir.Create();
while (r2d2.Read())
{
string filnavn = Convert.ToString(r2d2["filename"]);
string sizeString = Convert.ToString(r2d2["size"]);
int size = 0;
bool sizeOK = int.TryParse(sizeString, out size);
bool filnavnOK = false;
try
{
new System.IO.FileInfo(filnavn);
filnavnOK = true;
}
catch (ArgumentException erna)
{
throw new Exception("file not valid");
}
catch (System.IO.PathTooLongException)
{
throw new Exception("path not valid");
}
catch (System.Exception errrr)
{
throw new Exception("filename not supported", errrr);
}
if (filnavnOK && sizeOK && size > 0)
{
FileStream fs = null;
BinaryWriter bw = null;
if (_hashBrukteFilnavn.ContainsKey(filnavn))
filnavn = Path.GetRandomFileName().Substring(0, 5) + filnavn;
_hashBrukteFilnavn[filnavn] = true;
try
{
fs = new FileStream(Path.Combine(dir.FullName, filnavn), FileMode.OpenOrCreate, FileAccess.Write);
bw = new BinaryWriter(fs);
completePath = Path.Combine(dir.Name, filnavn);
int startIndex = 0;
int buffersize = 3072;
byte[] outbyte = new byte[buffersize];
long retval = r2d2.GetBytes(2, startIndex, outbyte, 0, buffersize);
while (retval == buffersize)
{
bw.Write(outbyte);
bw.Flush();
startIndex += buffersize;
retval = r2d2.GetBytes(2, startIndex, outbyte, 0, buffersize);
}
bw.Write(outbyte, 0, (int)retval);
}
catch (System.Exception err)
{
throw new Exception("error");
}
finally
{
if (bw != null)
{
bw.Flush();
bw.Close();
}
if (fs != null)
{
fs.Close();
fs.Dispose();
}
}
}
else
throw new Exception("file not valid");
}
}
|
|
|
|
|
Hi,
I would use a buffersize that is a multiple of 1K (1024), much larger than what you have, say 64K. And I wouldn't flush the BinaryWriter that often, once every MB or so is enough.
|
|
|
|
|
So if default packet size for MSSQL 2008 is 4096 (Kbytes?), I could for example try to use 2048 Kbytes wich gives me:
buffersize = 1024*2048=2097152?
And if I want to flush every MB, something like this? :
int startIndex = 0;
int buffersize = 2097152;
byte[] outbyte = new byte[buffersize];
long retval = r.GetBytes(2, startIndex, outbyte, 0, buffersize);
while (retval == buffersize)
{
bw.Write(outbyte);
if(startIndex%1048576==0)
bw.Flush();
startIndex += buffersize;
retval = r.GetBytes(WriterTabell.Reader.GetOrdinal("nef_elfil"), startIndex, outbyte, 0, buffersize);
}
bw.Write(outbyte, 0, (int)retval);
With this code I usually get only 1 loop wich seems to be faster
Is there any way I can find the optimal buffersize? Can .NET do the job for me (without using DataSet)?
|
|
|
|
|
Hi,
I would:
- use a smaller buffer (64KB, maybe 256KB), no need to waste 2MB;
- not write strange constants, just write it as you mean it 64*1024 , the compiler or JIT will evaluate it once for you;
- maybe flush every 16th iteration of the loop, so make it a for:
for(int iter=0; retval==buffersize; iter++) {
...
if ((iter%16)==0) bw.Flush();
...
}
Thomas ST wrote: any way I can find the optimal buffersize?
by experiment, however it won't matter much once you get it large enough, and it will vary depending on system specs and maybe system load.
Thomas ST wrote: Can .NET do the job for me (without using DataSet)?
don't know.
|
|
|
|
|
I don't have time to experiment
I'm going for a buffersize of 256*1024 (and I will let the compiler do the math ), and flushing every iter%16==0. The example I found online had buffersize=255 (equals 255 bytes right?), but it appears to be much faster with a bigger buffersize! It also seems like avoiding flush() is a good idea.
Thanks for helping me out
|
|
|
|
|
I store files as VARBINARY. To write them to disk I use:
using
(
System.IO.FileStream fs
=
fi.Open
(
System.IO.FileMode.Create
,
System.IO.FileAccess.Write
,
System.IO.FileShare.None
)
)
{
byte[] content = (byte[]) ds [ 1 ].Rows [ i ] [ "FileContent" ] ;
fs.Write ( content , 0 , content.Length ) ;
fs.Close() ;
}
The framework/OS can then buffer it as it sees fit.
(fi is a System.IO.FileInfo , ds is a System.Collections.Generic.IList<System.Data.DataTable> )
|
|
|
|
|
But then you use DataTable, doesn't this load everything into memory first?
|
|
|
|
|
Yes, and if that's a concern, just use a DataReader, which I do quite often.
|
|
|
|