|
Hi
Take time and Explain Exacly what you want.
Thanks
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
|
|
|
|
|
Add a LinkLabel in the designer or through code.
Set Text and Tag properties in the designer or in code:
linkLabel1.Text = "Code Project";
linkLabel1.Tag = "www.codeproject.com";
Add a Click event handler to your LinkLabel and in it put:
System.Diagnostics.Process.Start((string)linkLabel1.Tag);
Dave
|
|
|
|
|
I didn't think of that type of concept for the Tag property.
kudos
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
Hi,
I have a gridview, with a rowcommand. When I try to debug I can see it dosn't call the rowCommand (DeleteImage) Please can anyone tell me, why it does not run that rowCommand?
my code:
<asp:GridView ID="grdImages" runat="server" AutoGenerateColumns="false"
AutoGenerateEditButton="false" BorderColor="Transparent"
CellPadding="2" GridLines="vertical"
CellSpacing="0" DataKeyNames="filename"
ForeColor="Black"
ShowHeader="false" onsorting="grdImages_Sorting"
onrowcommand="grdImages_RowCommand">
<RowStyle BorderStyle="Dotted" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<img src='<%#Eval("imgImage")%>' alt="Image" width="50px" height="50px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="filename" runat="server" Text='<%#Eval("filename")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button CssClass="buttonsSmall" ID="btnDeleteImage" OnClientClick="return confirm('Billedet vil ikke længere kunne vises på livesitet. Er du sikker på, du vil slette billedet?');" Font-Size="8pt" runat="server" Text="Slet" CommandName="DeleteImage" CommandArgument='<%# Eval("filename")%>' />
</ItemTemplate>
<HeaderStyle />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<RowStyle CssClass="rowcolor" />
<AlternatingRowStyle CssClass="alternatingrowcolor" />
</asp:GridView>
protected void grdImages_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DeleteImage")
{
int imagename = Convert.ToInt32(e.CommandArgument);
string imagepath = Convert.ToString(Session["uploadpath"]);
File.Move(imagepath + '/' + imagename, Constants.ImageRecycleBin.UploadPath + imagename);
LoadImages(Convert.ToString(Session["uploadpath"]), "filename", "ASC");
}
}
Said with other words, when I hit the button in the gridview only the javascript event fires, not the RowCommand. I have tried to remove the javascript event with no success......
Kind regards,
simsen
|
|
|
|
|
DOHHHHHHH..... In my pageload event I updated the gridview without a (!IsPostBack).........
|
|
|
|
|
Hi guys,
I'm working on a c# tool to batch some compilation of different c++ projects
So evrything work fine except that I can't redirect the standard output for this command (it works for a simple dir c
For ex, this the code I use:
Process p = new System.Diagnostics.Process();
p.StartInfo = new ProcessStartInfo();
p.StartInfo.FileName = @"make.exe";
p.StartInfo.Arguments = "BUILD=release";
p.Start();
This works and open a cmd window
But I need to output the result in my c# app but when I enable the standard redirection like this
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
The process get stucked (the make process is started but it doesnt seem to do anything)
I have a do/while like this
do
{
if (!p.HasExited)
{
p.Refresh();
Console.WriteLine(" total processor time: {0}",
p.TotalProcessorTime);
}
} while (!p.WaitForExit(1000));
In fact the processor time is always null (0)
I also try these options but no more results:
p.EnableRaisingEvents = true;
p.StartInfo.CreateNoWindow = true;
Any ideas ???
Thanks in advance !
|
|
|
|
|
You are redirecting standard output.
As soon as make fills the output buffer, it will pause and wait until you read from the standard output.
So you have a deadlock there, make is waiting for your process to consume output, and your process is waiting for make to finish. You need to start reading output right away after starting the make process.
|
|
|
|
|
yeah I finally used the async method and it works:
just added my event handler on OutputDataReceived and ErrorDataReceived
thx guys !
|
|
|
|
|
Is the PATH env var set correctly?
Is the working directory set correctly?
What happens when you run this with out hiding the console, do you get the correct result?
Once you have verified the above, then start hiding the console, else you will just struggle forever.
|
|
|
|
|
hey guys...
on a form ive got 5 comboBoxes, they should all have the same data bound to them & this is how i do it
private void dataBindTimeCatComboBoxes()
{
DataSet dataSet = new DataSet();
SqlCommand selectCommand = new SqlCommand("Proc_SelectTimeCategoryName", sqlConn);
selectCommand.CommandType = CommandType.StoredProcedure;
SqlDataAdapter dataAdapter = new SqlDataAdapter();
dataAdapter.SelectCommand = selectCommand;
dataAdapter.Fill(dataSet, "tCat");
DataTable tCatTable = dataSet.Tables["tCat"];
comboBox2.DataSource = tCatTable;
comboBox2.DisplayMember = "TCat_Name_VC30";
comboBox2.ValueMember = "TCat_ID_SI";
comboBox3.DataSource = tCatTable;
comboBox3.DisplayMember = "TCat_Name_VC30";
comboBox3.ValueMember = "TCat_ID_SI";
comboBox4.DataSource = tCatTable;
comboBox4.DisplayMember = "TCat_Name_VC30";
comboBox4.ValueMember = "TCat_ID_SI";
comboBox5.DataSource = tCatTable;
comboBox5.DisplayMember = "TCat_Name_VC30";
comboBox5.ValueMember = "TCat_ID_SI";
comboBox6.DataSource = tCatTable;
comboBox6.DisplayMember = "TCat_Name_VC30";
comboBox6.ValueMember = "TCat_ID_SI";
}
the data does get bound, but the weird part is when i select a value in any one of the combo boxes ALL the combo boxes selected items change to that...
any ideas as to why? i really dont feel like making separate data sources for each one, it'll be redundant cuz all the combos have the same data.... but them sharing the same data source is the only reason that i can see for this strange behavior.
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Good Afternoon HarveySaayman
Well if you want your Combobox to Display data from one Data Source , it will be Simple, but the Behavior of Combox boxes in the Form will do , that am not sure why, but if you a for example searching based on what is selected , it will not give you a Problem, dont worry about it, i have never experienced a problem before and i understand what you mean. and if you want to bind your data fied to your Combobox, next time you can do it like this
private void dataBindTimeCatComboBoxes()
{
DataSet dataSet = new DataSet();
SqlCommand selectCommand = new SqlCommand("Proc_SelectTimeCategoryName", sqlConn);
selectCommand.CommandType = CommandType.StoredProcedure;
SqlDataAdapter dataAdapter = new SqlDataAdapter();
dataAdapter.SelectCommand = selectCommand;
dataAdapter.Fill(dataSet, "tCat");
comboBox2.DataSource = tCatTable;
comboBox2.DisplayMember = "tCat.TCat_Name_VC30";
comboBox3.DataSource = tCatTable;
comboBox3.DisplayMember = "tCat.TCat_Name_VC30";
comboBox4.DataSource = tCatTable;
comboBox4.DisplayMember = "tCat.TCat_Name_VC30";
comboBox5.DataSource = tCatTable;
comboBox5.DisplayMember = "tCat.TCat_Name_VC30";
comboBox6.DataSource = tCatTable;
comboBox6.DisplayMember = "tCat.TCat_Name_VC30";
}
Sometimes its not Necessaryto use datatable .remove that ValueMember property.
Hope it helps
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
|
|
|
|
|
create n-th(according number of your combobox) instances of DataView based on your DataTable and bind each DataView to each combobox
i hope this will help
dhaim
program is hobby that make some money as side effect
|
|
|
|
|
worked perfectly, thanx!
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Hi guys! one question if someone can help me. I have a listview and a checkbox. When the app is started the listview is populated from one folder. When the checkbox is checked the listview is automatically populating from different folder. Now, I want when the user will uncheck the checkbox, the listview to be populated again from the first folder. Any help? Thx
|
|
|
|
|
hi
Lets see what you have done so far, We cannot help you if we cannot see the code.
Thanks
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
|
|
|
|
|
I have done this:
RefreshView();
FileSystemWatcher fsw = new FileSystemWatcher("C:\\Photos\\Preview");
fsw.Changed += new FileSystemEventHandler(fsw_Changed);
fsw.Deleted += new FileSystemEventHandler(fsw_Changed);
fsw.Created += new FileSystemEventHandler(fsw_Changed);
fsw.EnableRaisingEvents = true;
the RefreshView method:
lvFiles.Items.Clear();
string[] files = Directory.GetFiles("C:\\Photos\\Preview");
foreach(string file in files)
{
lvFiles.Items.Add(file);
}
so that is trigerred when the user is checking the checkBox. When the checkBox again is unchecked, then nothing is happening. There I want to retrieve again the previous folder, in this case("C:\\Photos")
Thx
|
|
|
|
|
Hi All,
is there way (except running the method in try - catch block) how to determine (without considering the input arguments) if a format string is correct?
String.Format(string format, params object[] argumens);
thanks,
Stevo
zilo
|
|
|
|
|
You could probably use a RegularExpression.
I'd stick with Try/Catch, as you'd likely need it anyway.
|
|
|
|
|
I want to update a row in my local DB, and what should I use for updating? with executeNonQuery() it doesn't work, or I am doing something else wrong? Here is the code:
string updateQuery = "UPDATE Credentials SET Username = '" + txtUser.Text + "', Password = '" + txtPass.Text + "', Address = '" + txtAddress.Text + "' WHERE Username='" + user + "', Password='" + pass + "', Address='" + address + "'";
SqlCommand updateCom = con.CreateCommand();
SqlDataAdapter adapter2 = new SqlDataAdapter();
updateCom.CommandText = updateQuery;
adapter2.SelectCommand = updateCom;
DataSet updateDataSet = new DataSet();
adapter2.Fill(updateDataSet, dataTableName);
comm.ExecuteNonQuery();
con.Close();
thx for the help
|
|
|
|
|
Well, you know that this code is very insecure and easy to hack, right ?
What is con ? This does look messy to me. You don't need half of these objects, I am sure of that.
Here is an example I found with google:
Public Sub CreateMySqlCommand(myExecuteQuery As String, myConnection As SqlConnection)
Dim myCommand As New SqlCommand(myExecuteQuery, myConnection)
myCommand.Connection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
End Sub 'CreateMySqlCommand
IT's VB.NET, but it's clear which objects you should use, how you should use them, and where you're getting confused.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
con is the sql connection what I am declaring above the query. It doesn't work on the way you told me, but thx for the help anyway
|
|
|
|
|
As colin said, you are wide open for attacks. The code I posted, is all you need. If your SQL itself is broken, I don't know, I didn't look that deep, the code was too stuffed for me to worry.
Run your code in the debugger, get out the SQL string, run it inside the DB directly, and work out if you have errors in your SQL. Then fix your SQL access code. Then read up on SQL injection and make your code safe. Right now, it's a mess on all fronts.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
string updateQuery = "UPDATE Credentials SET Username = '" + txtUser.Text + "', Password = '" + txtPass.Text + "', Address = '" + txtAddress.Text + "' WHERE Username='" + user + "', Password='" + pass + "', Address='" + address + "'";
---> i think this is the first error, change to this :
string updateQuery = "UPDATE Credentials SET Username = '" + txtUser.Text + "', Password = '" + txtPass.Text + "', Address = '" + txtAddress.Text + "' WHERE Username='" + user + "' AND Password='" + pass + "' AND Address='" + address + "'";
SqlCommand updateCom = con.CreateCommand();
SqlDataAdapter adapter2 = new SqlDataAdapter();
updateCom.CommandText = updateQuery;
adapter2.SelectCommand = updateCom;
DataSet updateDataSet = new DataSet();
adapter2.Fill(updateDataSet, dataTableName);
con.Open();
comm.ExecuteNonQuery();
con.Close();
dhaim
program is hobby that make some money as side effect
|
|
|
|
|
dhaim wrote: change to this
NO! That is still vulnerable to SQL Injection Attacks.
|
|
|
|
|
i know, even in my code i will not do that, just reply submitted code
dhaim
program is hobby that make some money as side effect
|
|
|
|