|
wat u trying to achieve here? r u trying read the characters in between the two known string (ABC & JKL)
by the way how come the strings ("ABC" AND "JKL") got stored in char array.
if all of them are stored in char array, you can form these lettere by just appending them (upto 3 char) and compare it with Known string (ABC OR JKL)
|
|
|
|
|
Thank you carbon_golem for your response.
Srini,
srini wrote: wat u trying to achieve here? r u trying read the characters in between the two known string (ABC & JKL)
Yes I am. Let's say I want to write what is between ABC and JKL to a file and then write what's in between JKL and XYZ to the same file.
I can almost see what you are getting at. May I be so bold as to ask if you could expand on it a little bit more.
Also:
srini wrote: by the way how come the strings ("ABC" AND "JKL") got stored in char array.
I was just giving a clear example
|
|
|
|
|
You could use this:
string[] parts = mystring.Split('|');
Then, you could iterate through the string array (parts) to get your values. BTW, you probably don't want to end your string with a "|" character.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I am trying to save file (with path) extracted using OpenFileDialog to my app.config settings so the file gets loaded automatically on next execution. Can someone help
|
|
|
|
|
You want to use "settings", not app.config...
In project, right click the project tree item, and select
Add | New Item... | Settings File. <br />
<br />
<div class="ForumSig"> <div style="border:2px solid #FF9900;color:#000000;background-color:#FDF3CF;font-family:Arial;font-size:11px; padding:5px 5px 5px 5px;"><br />
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997<br />-----<br />"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001</div><br />
</div>
|
|
|
|
|
How do I use the settings. I was able to create settings but the data will be different from user to user.
|
|
|
|
|
You can have application-specific settings. You tend to learn things better (and faster) when you work them out on your own instead of asking a question and waiting for an answer.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
C#/Asp.net SQL question
=======================
Trying to Delete from SQL database through c# code
SqlDataSource s = (SqlDataSource)SqlDataSource1;
s.DeleteCommand = "Delete FROM Messages WHERE MessageID=id";
s.Delete();
('id' was defined like this
int id = Convert.ToInt32(TextBox1.Text.ToString());)
If I say MessageID = 5 instead of MessageID = id it works fine
(s.DeleteCommand = "Delete FROM Messages WHERE MessageID=5";)
Why can't I use variable instead of a value? Can you please help?
|
|
|
|
|
you probably meant to put the value of the variable into the delete command, not the name of the variable:
s.DeleteCommand = string.Format("Delete FROM Messages WHERE MessageID={0}", id);
|
|
|
|
|
Thanks a lot Jimmanuel! I really appreciate it!
First time using this message board and I got the right answer!
|
|
|
|
|
i want to start a program from my application with arguments, that program support file association, so i associate it with a file extension, and its works when i double click on file, but problem is that when i try to run that program with my app with argument then that program just run not open that file thats path is in arguments property and second problem is that its not rasing event when that program closed, here is the code i wrote :
Process tmp_process = new Process();
private void Main_Load(object sender, EventArgs e)
{
tmp_process.Exited += new EventHandler(exited_event);
}
private void button1_Click(object sender, EventArgs e)
{
tmp_process.StartInfo.Arguments = @"C:\new folder\abc.ghj";
tmp_process.StartInfo.FileName = @"C:\program.exe";
tmp_process.Start();
}
void exited_event(object sender, EventArgs e)
{
MessageBox.Show("Closed");
}
any solution ? thanks
Edited :
second problem solved after writing this line :
tmp_process.EnableRaisingEvents = true;
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
modified on Friday, May 30, 2008 12:59 PM
|
|
|
|
|
Put the arguments inside of quotes \"\" since it contains a space in the file path
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
thanks man it worked
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I'm running a process in a thread and want to put the results as they happen in a text box on my form. Is that possible? I cant seem to make it work.
|
|
|
|
|
It's possible, you just have to transfer the results to the UI thread before updating the text box. 2 common ways of doing this:
textBox.Invoke((MethodInvoker)delegate()
{
textBox.Text = "here are the results...";
}); The other common way and recommended way is to use a BackgroundWorker[^] component. It lets you run work on a background thread and call worker.ReportProgress, which fires an event on the proper thread, allowing you to update your UI in there.
Life, family, faith: Give me a visit.
From my latest post: "When Constantine severed the Hebrew origins of this faith in Messiah, a new religion was officially created. It is this religion that Orthodox Jews fear their relatives and friends becoming members of."
Judah Himango
|
|
|
|
|
I don't believe the cast to MethodInvoker is necessary.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
It is because the parameter type is Delegate. The compiler cannot infer which delegate type you mean when passing in an anonymous method; you'll get a "cannot convert anonymous method to type System.Delegate because it is not a delegate type" compiler error.
Life, family, faith: Give me a visit.
From my latest post: "When Constantine severed the Hebrew origins of this faith in Messiah, a new religion was officially created. It is this religion that Orthodox Jews fear their relatives and friends becoming members of."
Judah Himango
|
|
|
|
|
I've being using objectDataSources to populate some data controls lately. My data access objects return collections of objects rather than DataTables or DataSets. The inherent problem with this is you can't sort a collection by any column (e.g. if I had an EmployeeCollection filled with Employee objects I couldn't sort by Employee.LastName in one method and then Employee.Id in another). So I set out to create a sortable list I could inherit from and be able to sort my collections.
What I have is below, but the problem I have is that I'm converting my generic variables to strings so that I can compare them. I suppose this works fine as long as I override ToString() on my objects so that it makes sense, but it seems like a bit of a kludge. Does anyone have any other ideas that might work?
using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
namespace IssueTracker.Business.Collections
{
public class SortableList<T> : List<T>
{
public void SortBy(string sortExpression, SortDirection sortDirection)
{
Sort(delegate(T t1, T t2) { return Compare(t1, t2, sortExpression, sortDirection); });
}
private static int Compare(T t1, T t2, string propertyName, SortDirection sortDirection)
{
object t1Value = t1.GetType().GetProperty(propertyName).GetValue(t1, null);
object t2Value = t2.GetType().GetProperty(propertyName).GetValue(t2, null);
StringComparer comparer = StringComparer.CurrentCulture;
int result = comparer.Compare(t1Value.ToString(), t2Value.ToString());
if (sortDirection == SortDirection.Descending)
result = result*-1;
return result;
}
}
}
|
|
|
|
|
I'm not sure what you are trying to do but List<> is already sortable
public class Employee
{
public string FName;
public string LName;
public Employee(string fname, string lname) { FName = fname; LName = lname; }
public static int CompareFirstName(Employee e1, Employee e2)
{ return e1.FName.CompareTo(e2.FName); }
public static int CompareLastName(Employee e1, Employee e2)
{ return e1.LName.CompareTo(e2.LName); }
}
List<Employee> list = new List<Employee>();
list.Add(new Employee("Joe", "Smakatelly"));
list.Add(new Employee("Sue", "Rummy"));
list.Sort(Employee.CompareFirstName);
Console.WriteLine("First Name");
foreach (Employee e in list)
Console.WriteLine("{0} {1}", e.FName, e.LName);
list.Sort(Employee.CompareLastName);
foreach (Employee e in list)
Console.WriteLine("{0} {1}", e.FName, e.LName);
led mike
|
|
|
|
|
Hello my name is Henry Javier.
I need implement an application to take the total control of PC, this is similar of a cyber control application....
please helme... this is for my university...
I sorry my english is very bad....
Hola a todos mi nombre es Henry Javier y necesito crear una aplicacion en C# la cual sea capaz de tomar el control total de una PC algo similar a un cyber cafe...
me pueden ayudar....
por favor
|
|
|
|
|
hendryck wrote: I sorry my english is very bad....
No importa. Mi espan~ol está mucho mas mal.
But, you know the word "café" also exists in English which results in "cybercafé"
Coffee is the drink. A "café" is a place which sells coffee for consumption on the premisis.
|
|
|
|
|
hi there,
has anyone any idea of how i could implement the coverflow (mac) or shift window switching (vista) effect?
i've tried some ideas like quadric or exponential methods but they didn't turn out..... so here i am asking for some advice?
thanks,
andreea
|
|
|
|
|
this is my code. or part of it
{
:
:
this.sqlConnection1.ConnectionString = "workstation id=S6W6Q4;packet size=4096;integrated security=SSPI;data source=S6W6Q" +
"4;persist security info=True;initial catalog=master";
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO [\'List For Haj Ballot$\'] ([List For Haj Ballot 2008], F2, F3, F4, F5," +
" F6) VALUES (@Param1, @F2, @F3, @F4, @F5, @F6); SELECT [List For Haj Ballot 2008" +
"], F2, F3, F4, F5, F6 FROM [\'List For Haj Ballot$\']";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param1", System.Data.SqlDbType.Float, 8, "List For Haj Ballot 2008"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@F2", System.Data.SqlDbType.Float, 8, "F2"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@F3", System.Data.SqlDbType.NVarChar, 255, "F3"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@F4", System.Data.SqlDbType.NVarChar, 255, "F4"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@F5", System.Data.SqlDbType.NVarChar, 255, "F5"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@F6", System.Data.SqlDbType.NVarChar, 255, "F6"));
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "\'List For Haj Ballot$\'", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("List For Haj Ballot 2008", "List For Haj Ballot 2008"),
new System.Data.Common.DataColumnMapping("F2", "F2"),
new System.Data.Common.DataColumnMapping("F3", "F3"),
new System.Data.Common.DataColumnMapping("F4", "F4"),
new System.Data.Common.DataColumnMapping("F5", "F5"),
new System.Data.Common.DataColumnMapping("F6", "F6")})});
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.LimeGreen;
this.ClientSize = new System.Drawing.Size(686, 548);
this.Controls.Add(this.label8);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.label7);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.label6);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.label5);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.label4);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1";
this.Text = "APL Haj Ballot System";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
/*try
{
//SqlConnection dataConnection = new SqlConnection();
//dataConnection.ConnectionString = "Integrated Security=true; Initial Catalog=master; Data Source = s6w6q4";
//dataConnection.Open();
//MessageBox.Show("connected");
SqlCommand dataCommand = new SqlCommand();
}
catch(Exception e)
{
Console.WriteLine("An error occurred accessing the database:" + e.Message);
}*/
}
SqlConnection dataConnection = new SqlConnection();
SqlCommand dataCommand = new SqlCommand();
//SqlDataReader sdr = new SqlDataReader();
/*private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection dataConnection = new SqlConnection();
SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = dataConnection;
dataConnection.ConnectionString = "Integrated Security=true; Initial Catalog=master; Data Source = s6w6q4";
dataConnection.Open();
//dataCommand.Connection = dataConnection;
//dataCommand.CommandText = "SELECT Emp#, Name, Designation, Department, Location FROM master";
dataCommand.CommandText = "select (@Emp#, @Name, @Designation, @Department, @Location)From master";
//textBox1.DataBindings.Add("Text", dataConnection.Database.s6w6q4.master,"s6w6q4.master.Emp#");
SqlDataReader datar = dataCommand.ExecuteReader();
while(datar.Read())
{
int empid = datar.GetInt32(1);
//textBox1.Text = Convert.ToString(empid);
string empname = datar.GetString(2);
string desig = datar.GetString(3);
string dept = datar.GetString(4);
string loc = datar.GetString(5);
}
}*/
private void Form1_Load(object sender, System.EventArgs e)
{
SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString = "Integrated Security=true; Initial Catalog=master; Data Source = s6w6q4";
dataConnection.Open();
MessageBox.Show("Connected");
}
private void button1_Click(object sender, System.EventArgs e)
{
DataTable tbl_master = new DataTable();
dataConnection.ConnectionString = "Integrated Security=true; Initial Catalog=master; Data Source = s6w6q4";
//SqlConnection conn_offers = new SqlConnection("Integrated Security=true; Initial Catalog=master; Data Source = s6w6q4");
SqlDataAdapter da_offers = new SqlDataAdapter("SELECT 1 * FROM tbl_offers master BY NewID()", dataConnection);
da_offers.Fill(tbl_master);
}
}
}
with commented stuff.
i've tried various methods as can be seen, but nothing is helping n the project is due sunday.
this is what i want. a data table, called master, has been connected with my project.
it is a list of employees, and a ballot has to take place for a promotion. if that name would be dismissed, the button would be pressed again to retrieve another name, excluding the one that was chosen before.
i want to display the various attributes of the employee in textboxes. i hav no idea wat is happening anymore, i've been on this project for a week, n i regret i dint come here earlier.
im very very distressed. pls help me ASAP, pls get that code above right. n tel me how 2 kno if the connection is right.
as u can c, i've made the project so that as soon as the form loads, it tels me that a connection to database has been established. n it does so. but its not retrieving data. if i hav to display the data any other way, i will, but just help me outta this mess!
|
|
|
|
|
n the database is an excel file, btw.
|
|
|
|
|
what type of help you want .tell me
hi friends do somthing different........from other..........
|
|
|
|
|