|
Agreed. This is definitely a coding style issue.
Debating relative allocation performance or stack overhead for the nul string is just plain retarded imho.
|
|
|
|
|
|
Hi I'm suffering with following error "Must declare the scalar variable "@name_txtbx". " here is my code
public void Bindgrid()
{
try
{
dt.Clear();
string query = "Select * From consumer where name_con like ' + txtbx_name.Text + %' AND ward_no = " + txtbx_ward.Text + "";
query = "select * from consumer where name_con = '" + txtbx_name.Text + "' And name_con_father = '" + txtbx_con_father.Text + "' And ward_no = " + txtbx_ward.Text + " ";
con.ConnectionString = constr;
cmd.Parameters.AddWithValue("@name_txtbx", txtbx_name.Text);
cmd.Parameters.AddWithValue("@ward_txtbx", txtbx_ward.Text);
cmd.Parameters.AddWithValue("@fname_txtbx", txtbx_con_father.Text);
cmd.CommandText = "select * from consumer where name_con like % @name_txtbx %OR name_con_father like % @fname_txtbx % Or ward_no like % @ward_txtbx ";
query = "select * from consumer where name_con = @name_txtbx %OR name_con_father like % @fname_txtbx % Or ward_no like % @ward_txtbx ";
SqlDataAdapter da = new SqlDataAdapter(query, constr);
da.Fill(dt);
gv_search.DataSource = dt;
gv_search.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
please help me out, I'm new in programming field
thanks
|
|
|
|
|
Why do you define query twice ?
You should add the Parameters AFTER you define the CommandText. However, the fact that you define query THREE times I just realised, makes me think you are adding code at random. Try to think it through and understand what each step is doing.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
hi Paw Jershauge
If you can Explain Exactly what you want to achieve and what have you do so far, it would be easy for us to help you.
Are you looking for a way to increament a variable on a loop or what?
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
|
Ok so heres what works in the search pattern:
\b[a-zA-Z0-9]\b\s=\s\(\b[a-zA-Z0-9]\b\s\+\s1\) = finds x = (x + 1)
But i dont know how the replace patterne should be...
With greate code, comes greate complexity, so keep it simple stupid...
|
|
|
|
|
This regex will work just fine:
((\w+)\s*=\s*\(\s*\2\s*\+\s*1\s*\))
with the replacement string
$2++
You need to replace \w+ with a proper pattern for only valid variable names though.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
But it's wrong. Yours will also match
x = (y + 1)
because no backreference to the first variable is used for the second, so both variables might not necessarily be the same, which violates the rule i=i+1 <=> i++
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
hi,
I am triying to assing values dynamically toa array string here i am triying to write
code as follows
this.openFileDialogimage.ShowDialog().Equals(DialogResult.OK);
string drname = Path.GetDirectoryName(this.openFileDialogimage.FileNames[0]);
foreach (string file in this.openFileDialogimage.FileNames)
{
int i;
for (i = 0; i <= Convert.ToInt32(openFileDialogimage.FileNames.Count()); i++)
{
string[] str = new string[Convert.ToChar(openFileDialogimage.FileNames.Count())];
}
}
help me how to procede,
how i can send the file name which has be selected in open dialog box to a string .
Regard's,
Maruthi.
|
|
|
|
|
The FileNames property already returns an array of strings, so all you need is:
if (this.openFileDialogimage.ShowDialog() == DialogResult.OK) {
string[] str = this.openFileDialogimage.FileNames;
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
Using its filename property.
|
|
|
|
|
I am on a multi threaded application which is a file downloader from FTP server. I have created a producer/consumer style custom class which manages a download queue and processes the items one by one in the queue. I am adding delegate instances to the queue and when one thread picks the item, it invokes the delegate instance to start the work.
For downloading files from FTP, I used WebClient classes DownloadFileAsync . My custom class wraps webclient and it's events. I have noticed this is downloading only 2 files at a time. All the other requests are queued and will be executed one by one.
My "DownloadQueue" class is working well. It creates the specified number of threads and dequeues each item when threads become free. I found problem is in DownloadFileAsync method of WebClient . It uses asynchronous fashion and obviously using a thread pool thread to download the file. I learned that, thread pool creates only 2 threads by default and all the other requests will be queued until threads become free. I tried increasing the thread count by ThreadPool.SetMinThread() , but it didn't worked. Still it's downloading only two files at a time.
I am sure I have called DownloadFileAsync 5 times from 5 threads. 2 of them started immediately and remaining 3 gets queued. Any idea to solve this issue ?
|
|
|
|
|
N a v a n e e t h wrote: I have noticed this is downloading only 2 files at a time.
How many CPU cores you have? Async calls normally utilize the cores (via ThreadPool, dont know details exactly). Use 'direct' threading to do more.
|
|
|
|
|
Thanks Leppie,
I am on a core2duo machine.
leppie wrote: Use 'direct' threading to do more.
As I said, I am using WebClient classes DownloadAsync method. It works in asynchronous fashion. Looks like I have to implement FTPWebRequest class manually than using WebClient. Any other ideas ?
|
|
|
|
|
N a v a n e e t h wrote: Looks like I have to implement FTPWebRequest class manually than using WebClient. Any other ideas ?
You dont have to.
Just use WebClient synchronously within a Thread of its own.
|
|
|
|
|
leppie wrote: Just use WebClient synchronously within a Thread of its own.
Thanks again leppie.
It won't report progress. I need to update my view (progress bar) too.
|
|
|
|
|
Could it be a limit on the FTP server? Maybe it blocks more than 2 requests from the same IP address (to ensure QOS)?
|
|
|
|
|
Thanks Senthil.
I am testing on local FTP and it allows around 1000 connection simultaneously. Any ideas ?
|
|
|
|
|
Hi
I work at a cancer department and we are using a planning system to plan the radiation therapy for the patients. Some of the data from the planning system can be exported, but it only exports it in Excel 4.0 Worksheet format. I am trying to write an application that can automate some processes. We do not have easy access to these Excel files and what I am trying to do is to have my C# application copy all the data on a worksheet in this Excel 4.0 file and paste it into a new Excel 2003 worksheet where we can manipulate the date.
I am using the following code to copy the data into the clipboard:
Excel.Application objApp = new Microsoft.Office.Interop.Excel.Application();
Excel.Workbook theWorkbook = objApp.Workbooks.Open(excelFile,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value);
Excel.Sheets sheets = theWorkbook.Worksheets;
Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
range = worksheet.get_Range(startCell, endCell);
range.Copy(Type.Missing);
When I run this and selects the Excel 4.0 file it comes up with the following error:
"External table is not in the expected format."
When I run the code and accesses Excel 2003, then it works fine. It seems to be a Excel version issue.
I am using Visual Studio 2005.
Does anyone know how I can access the data in Excel 4.0?
Thanks.
Kobus
|
|
|
|
|
You'll probably need older version of the Microsoft Office Dlls to access older versions of Excel, but you'll probably have a hard time finding them for Excel 4 seeing as it predates .Net by 10 years
|
|
|
|