|
I want check connection.state in 50 milisecond.If connection.state not open in 50 miliseconds my programe will close.I use connection timeout=1 in connection string.But connection time out not to be useful.How connection check open or not open in 3 miliseconds???
Thanks...
|
|
|
|
|
What connection?? Connection to what??
YOu want it to connection in 50 milliseconds or less?? For most connection types that I know of, you're asking alot. 3 milliseconds?? Depending on what you're connecting to and what's between the two components, the connection is, most likely, not going to be made in that time.
|
|
|
|
|
If you want to tiemout a connection in milliseconds, then you're going to have to open the connection in it's own thread and use a timer that supports the resolution you want to kill that thread if the time limit is reached. The "Connection Timeout" property on the connection string can only handle seconds.
|
|
|
|
|
hi
I need a code for find all file and directory in specific directory
Can you help me?
regard
|
|
|
|
|
Take a look at Directory.GetDirectories (I think) and Directory.GetFiles.
Regards,
Rob Philpott.
|
|
|
|
|
|
mahdiehIR wrote: Can you help me?
Sure, why not. Read the top (first) post in the form titled "How to get an answer to your question". Pay attention to item #2.
|
|
|
|
|
Try this method:
public List<fileinfo> getAllFiles(DirectoryInfo currentDir)
{
List<fileinfo> collection = new List<fileinfo>();
foreach (FileInfo file in currentDir.GetFiles())
collection.Add(file);
foreach (DirectoryInfo dir in currentDir.GetDirectories())
collection.AddRange(getAllFiles(new DirectoryInfo(dir.FullName)));
return collection;
}
for example:
DirectoryInfo dirInfo = new DirectoryInfo(@"C:\exampleDest");
List<fileinfo> newList = getAllFiles(dirInfo);
newList now contains all FileInfo objects from the files in Directory exampleDest and it's subDirectories.
|
|
|
|
|
If you're only getting the subdirectories to parse files in all the subdirectories of a root directory, then I would suggest this.
DirectoryInfo rootDirectory = new DirectoryInfo(@"c:\Windows");
FileInfo[] fileList = rootDirectory.GetFiles("*.*", SearchOption.AllDirectories);
this will fill fileList with all the files found in rootDirectory and all the files in the subdirectories under rootDirectory.
So everything in C:\Windows and C:\Windows\*
|
|
|
|
|
Hey guys,
I m trying to emport some data from excel using Oledb.
wen i use this connectionstring everything works fine:
string sConnectionString = @" Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Book1.xls;Extended Properties=""Excel 8.0;HDR=YES;"" ";
Bud wen i try to pass the data source as parameter like this:
string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source="+ datasource+";"+"Extended Properties= Excel 8.0;"+"HDR=YES;";
then i get the error:
Could not find installable ISAM.
any idea how to pass the data source parameter in this case?
|
|
|
|
|
Djavid j wrote: string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source="+ datasource+";"+"Extended Properties= Excel 8.0;"+"HDR=YES;";
So you are already developing solutions even though you have not yet found the String.Format(...) function. Hmmm... interesting boring
|
|
|
|
|
You could always try:
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|\\"
+ TheExcelFileYouNeed + "; Extended Properties = 'Excel 8.0;HDR=Yes;IMEX=1'"
As Mike said..you need to learn a bit more about strings...
Regards
Mick Curley
A craft is an enemy if not well learned.
|
|
|
|
|
I try to use the automatically arrange the edit box by putting it in a Tablelayoutpanel, but it does not work at all!
why? it is strange to me.
I want to confirm it works or not in VC#2005. It seems it works in VC++2005.
THANKS
|
|
|
|
|
Hi all
i have implemented a small application in which a button is placed named addRow when user clicks tht button a row is added in a grid view,whever user clicks it row will be added to the existing gridview i have done this with the following code now the problem is when i refresh the page the row is added or when i click any server control the row is also added bt i dont want this i just want the row shud be added when the button name addRow is clicked only.
any help will be greatly appreciated.thanks in advance
Code: ( cpp )
1.
protected void Page_Load(object sender, EventArgs e)
2.
{
3.
if (!Page.IsPostBack)
4.
Session["dt"] = null;
5.
6.
}
7.
protected override void OnPreInit(EventArgs e)
8.
{
9.
base.OnPreInit(e);
10.
if (Request.Form["hf"] == "true")
11.
addGVRow();
12.
hf.Value = string.Empty;
13.
}
14.
15.
16.
private void addGVRow()
17.
{
18.
DataTable dt = (DataTable)Session["dt"];
19.
int counter = 0;
20.
if (dt == null)
21.
{
22.
dt = new DataTable();
23.
dt.Columns.Add("seq");
24.
}
25.
else
26.
counter = dt.Rows.Count;
27.
DataRow dr = dt.NewRow();
28.
dr[0] = counter + 1;
29.
dt.Rows.Add(dr);
30.
gv.DataSource = dt;
31.
gv.DataBind();
32.
Session["dt"] = dt;
33.
}
and on aspx page for the button
<asp:button id="btn" runat="server" text="Add" onclientclick="javascript:document.getElementById('hf').value='tr ue';return true;">
|
|
|
|
|
Hi all
How i can read xls file with out using standard COM library of Excel(Microsoft Excel x.0 Object Library), because it work very slow. I try to export data from XLS file to XML file first and after
read this XML file, but unfotunately Excel 9.0 library has not this functionality.
Any idea please.
-- modified at 9:22 Thursday 29th November, 2007
|
|
|
|
|
Dear Friend,
Hi.
string strFileName = "fileName.xls";
System.Data.OleDb.OleDbConnection excelConn = new System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source= '" + strFileName + "'; " + " extended properties=excel 8.0;");
string strsql = "Select * from [Sheet1$]";
System.Data.OleDb.OleDbDataAdapter excelDataAdap = new System.Data.OleDb.OleDbDataAdapter(strsql, excelConn);
dsExcel = new DataSet();
if (excelConn.State == ConnectionState.Closed)
{
excelConn.Open();
}
//Select the values from Excel
excelDataAdap.Fill(dsExcel);
GridView1.DataSource = dsExcel;
GridView1.DataBind();
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(strsql, excelConn);
System.Data.OleDb.OleDbDataReader dr = cmd.ExecuteReader();
string sqlConnectionString = "Data Source=srvr;Initial Catalog=db;User Id=usr;Password=pwd";
// Bulk Copy to SQL Server
System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(sqlConnectionString);
bulkCopy.DestinationTableName = "ExcelData";
bulkCopy.WriteToServer(dr);
I hope this will helps u.....
"Good Thing Goes With Good People..."
|
|
|
|
|
I have a P-Invoek function to call with a pointer to pointer Parameter wich should return
an Array.
The function call is this:
public static unsafe extern uint lhs_asrGrmGetWords(LHS_HSAFE hGrm, ASR_WORDINFO** ppWordInfo, void* pulNbrOfWords);
The problem is in the second parameter.
[StructLayout(LayoutKind.Sequential)]
unsafe public struct ASR_WORDINFO
{
public uint ulID;
public void* szWord;
}
This way I can make a parameter with a double pointer for one item of the array:
NbrOfWords = 0;
void* pulNbrOfWords = &NbrOfWords;
ASR_WORDINFO pointerValue;
ASR_WORDINFO* pointer1 = &pointerValue;
ASR_WORDINFO** pointer2 = &pointer1;
result = VoConPInvoke.lhs_asrGrmGetWords(hGrm, pointer2, pulNbrOfWords);
pointerValue holds now one element of the array and NbrOfWords the value of the third parameter.
For a single pointer for an Array it works like this:
ASR_WORDINFO[] pointerValue = new VoConStruct.ASR_WORDINFO[10];
fixed (VoConStruct.ASR_WORDINFO* pointer1 = pointerValue)
{
result = lhs_asrGrmAnotherWithOnePointer(recogObjects.hGrm, pointer1, pulNbrOfWords);
}
pointerValue holds the array and NbrOfWords the value of the third parameter (= the Length of the Array).
But how do I make it for the whole array???
This won't compile:
NbrOfWords = 0;
void* pulNbrOfWords = &NbrOfWords;
ASR_WORDINFO[] pointerValue; // with the []
ASR_WORDINFO* pointer1 = &pointerValue;
ASR_WORDINFO** pointer2 = &pointer1;
result = VoConPInvoke.lhs_asrGrmGetWords(recogObjects.hGrm, pointer2, pulNbrOfWords);
How to make this compile???
G.M. van Heuckelum
mailto: g.van.heuckelum@agripartner.nl
Software Engineer
|
|
|
|
|
maybe this[^] helps
greets
m@u
|
|
|
|
|
this[^] is in c++ Handle to Object on Managed Heap.
In C# ^]is something different, so I can not use this[^] in my C# code.
|
|
|
|
|
Boy I really needed a laugh, thank you.
|
|
|
|
|
I have a checked list box that has about 20 items in the list. At a certain time I need to lock the control from the user so no more items can be checked or unchecked. If I set the control's Enabled property to false, the user cannot check any items but they are also prevented from scrolling down the list to see what items are checked.
How do I disable checking but allow the user to still scroll through the list? Thanks!
|
|
|
|
|
You may want to handle ItemCheck event and write some code to decide if item's CheckState value should be changed or not.
|
|
|
|
|
I'm trying to do the following but it does not compile?
<code>struct ProxyHolder<TInterface> where TInterface : class
{
public ProxyHolder(ClientBase<TInterface> client, object clientLock)
{
}
}
Dictionary<Type, ProxyHolder<TInterface>> proxies;</code>
This fails on the TInterface in the Dictionary declaration.
Is there any way of achieving this? For ProxyHolder I can pass in Type instead of TInterface, which would compile but then this code would fail
<code>proxies.Add(typeof(JobManagerClient), new ProxyHolder<IJobManager>(jobManager, jobManagerLock));</code>
with:
Argument '2': cannot convert from '<IJobManager>' to 'ProxyHolder<System.Type>'
Kevin
|
|
|
|
|
Kevin McFarlane wrote: This fails on the TInterface in the Dictionary declaration.
Thats because TInterface is not declared. You will need to specify a type, or move that declaration into the ProxyHolder struct (if possible) where TInterface is defined.
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
So TInterface has to be a closed constructed type right? That's the problem, I don't know in advance what type it should be.
Kevin
|
|
|
|