|
Hi to all,
I want to check the specified file exist in the specified directory or not....
how can i do this?
Pravin
|
|
|
|
|
create the instance of FileInfo class
//FileInfo f;
initialze that in the following manner
//f = new FileInfo("something.txt");///mention the complete path
and then use this property to know whether this file exists or not
///if(f.Exists == false) /// means the file doesn't exist
ok
|
|
|
|
|
|
Hi
In order to check if a specific file exists
You can use the File.Exists static method , you can also use the
FileInfo.Exists property but for that you need to construct a FileInfo Object
|
|
|
|
|
Thanks Nissims,
i have used here object.FileExists(filespec) method.
Pravin
|
|
|
|
|
You can directly check the path using
if(System.IO.File.Exists(Path))
Regards
DilipRam
|
|
|
|
|
Hi Everybody,
We have a problem in displaying the data combining two tables....
we have table1 where a primary key is set to field1 and another table table2 where a foreign key is set to field1 with the same name as it is in the table1.
we gave the query to the data adapter as
" SELECT field1,field2,field3 FROM table2,table1 WHERE table1.field1=table2.field1";
But all the table2 rows are displayed without satisfying the condition we gave in the sql query.
Please help us at the earliest.
Thanks and Regards,
Priya
|
|
|
|
|
SELECT table1.field1,table1.field2,table1.field3
FROM table1 inner join table2 on table1.field1=table2.field1
Rami Abdalhalim
|
|
|
|
|
Thanks ..... It Worked....
But the filtered row is repeatedly getting displayed in the output table.....
We want the row to be displayed only once....
Please suggest..
Priya
|
|
|
|
|
Hello Everyone,
Can anybody let me know "Wht's the benefits of the Virutal function in C#"
|
|
|
|
|
To get polymorphic behavior.
|
|
|
|
|
Can u explain it further.....................
|
|
|
|
|
Given your question I suspect object oriented programming is new to you. A forum really isn't ideal for learning a topic as large as OO from scratch. I recommend getting a book or spend a lot of time researching on the internet (google is your friend). You can for example read wikipedia for a VERY broad overview:
Object Oriented programming on Wikipedia[^]
If you have specific questions not easily answered by googling, then it is time to ask in the forum.
|
|
|
|
|
By marking the function as virtual you are indicating that it is legal for a derived class to "overload" that function and change the behavior, either completely or partially.
This concept is generally called polymorphism and is one of the central concepts in object oriented programming. There are several good websites and reference books that explain OO programming theory, so you might want to check those out and get in order to get a better understanding.
|
|
|
|
|
Hai Everbody,
Warm Greetings!
Can any one suggest me the techniques and methods for license key generation.
Also how can i identify a system uniquely using the hardware information such as Processor ID and MAC Address.
And how can I get the Processor ID.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Well following are the licensing schemes:
- Per Processor licensing
- Per User licensing
- Per Machine licensing (unlimited per machine)
- One time license(for installations etc)
You can ger Processor ID from Win32_Processor and MAC from Win32_NetworkAdapterConfiguration.
A better approach would be to use Win32_ComputerSystemProduct.UUID for uniquely identifying a system and then enforce various licensing schemes
before c# there was darkness
|
|
|
|
|
hk11 wrote: You can ger Processor ID from Win32_Processor and MAC from Win32_NetworkAdapterConfiguration.
A better approach would be to use Win32_ComputerSystemProduct.UUID for uniquely identifying a system and then enforce various licensing schemes
Is these are namespaces.
If so where can i get it.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
hk11 wrote: A better approach would be to use Win32_ComputerSystemProduct.UUID for uniquely identifying a system and then enforce various licensing schemes
I know this post is old, but...
The UUID you cited is not adequate on home-built systems. On such systems your uuid is going to be 00000000-0000-0000-0000-000000000000 or FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF .
Only pre-built machines (from Dell, Gateway, etc) or laptops will have a unique UUID, and even then, the UUID may be identical in an organization that builds machines from a common OS image CD.
If you could somehow identify a way to somehow set the UUID in the event of the all-0 or all-F situation, I'd be happy to hear about it.
"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 have 3 columns in my table. They are Yes\No filelds. If the row is Yes i want to take the header name of the column.in the below example if morning is yes i want to take Morning in datagrid
eg: if
Morning Evening Afternoon
Yes No YES
Yes Yes No
No Yes Yes
in the above example in first row Morning and Afternoon is True.
I want to retieve this to a Datagrid column Named Session.. i want to retrieve the above data to Session column
. in the case of first row i want to show like this in datagrid column
Session
Morning, Evening
Please help me to write Query and code
|
|
|
|
|
I am trying to update a record using 2 variables in my UPDATE statement in C#. The Statement is executed using ExecuteNonQuery() which returns 0 - correctly indicating that 0 records were updated - but I can't figure out why. I have included source code and log data that I collected.
I appreciate any help in exposing my screw-up.
Bill
//*****************************************
// BEGIN OF CODE STUB
//*****************************************
// FYI:
// myConn is a Global of type OleDbConnection
// and gets opened in the
// fnGetConnectedToDatabase() call
int nCustID = -1;
int nRouteID = -1;
//**************************************************************
// Get the RouteID for the selected RouteName
//**************************************************************
// Find the index in the ComboBox
// Look up the associated RouteID in listBoxRouteIDs
int idx = comboBoxRoutes.SelectedIndex;
if (idx != -1)
{
nRouteID = Convert.ToInt32(listBoxRouteIDs.Items[idx]);
foreach (string sCustName in listBoxToAddToRoute.Items)
{
CommonSubsClass.WriteToLog("Open Connection"); // DEBUG
fnGetConnectedToDatabase();
// THIS CODE WORKS FINE IN LOOKING UP THE CUSTOMER ID
// 1. Find out the Customer ID for this customer
// 2. Update the CustomerInfo record
string selectSQL = "SELECT CustomerInfo.* FROM CustomerInfo WHERE CustomerInfo.Customer = ?";
myDataAdapter = new OleDbDataAdapter(selectSQL, myConn);
OleDbCommand selectCMD = new OleDbCommand(selectSQL, myConn);
myDataAdapter.SelectCommand = selectCMD;
// Add parameters and set values.
selectCMD.Parameters.Add("@CustName", OleDbType.VarChar, 40).Value = sCustName;
// Instantiate a DataSet
DataSet CustomerDataset = new DataSet();
// Populate the data table "CustomerInfo"
CustomerDataset.Clear();
myDataAdapter.Fill(CustomerDataset,"CustomerInfo");
foreach (DataRow myRow in CustomerDataset.Tables["CustomerInfo"].Rows)
{
// Need to handle Null values
try
{
if (myRow["cust_id"] != DBNull.Value)
{
nCustID =(int) myRow["cust_id"];
}
}
catch (InvalidCastException ex)
{
MessageBox.Show("Error in InvalidCastException...\n" + ex.Message + "\n" + ex.StackTrace);
}
}
CommonSubsClass.WriteToLog("Close Connection [1]"); // DEBUG
myConn.Close();
CommonSubsClass.WriteToLog("Open Connection [2]"); // DEBUG
fnGetConnectedToDatabase();
//************************************************
// I BELIEVE THE PROBLEM MUST BE BELOW HERE !!!
// NOTES:
// I HAVE CONFIRMED TABLE AND FIELD NAMES
//************************************************
string updateSQL = "UPDATE CustomerInfo SET RouteID = @RouteID WHERE cust_id = @cust_id";
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand cmd;
// Create the UpdateCommand.
cmd = new OleDbCommand(updateSQL, myConn);
cmd.Parameters.Add("@cust_id", OleDbType.Integer).Value = nCustID;
// V2.2.5 - 04-JAN-2007
// Added RouteID to CustomerInfo table
cmd.Parameters.Add("@RouteID", OleDbType.Integer).Value = nRouteID;
CommonSubsClass.WriteToLog(updateSQL + " [" + nCustID.ToString() + "] [" + nRouteID + "]");
try
{
int retval = -1;
retval = cmd.ExecuteNonQuery();
string sCustomerInfoChanged = "";
sCustomerInfoChanged = "Customer Route Changed: [CUST ID:" + nCustID.ToString() + "] to " + nRouteID;
CommonSubsClass.WriteToLog(sCustomerInfoChanged);
CommonSubsClass.WriteToLog("cmd.ExecuteNonQuery() Returned: " + retval.ToString());
}
catch (Exception ex)
{
MessageBox.Show("DB Update Exception...\n" + ex.Message + "\n" + ex.StackTrace);
}
//*****************************************
// END OF CODE STUB
//*****************************************
//************************************************************
HERE ARE MY LOG ENTRIES (CommonSubsClass.WriteToLog() CALLS:
9/17/2007 10:00:54 PM: Open Connection
9/17/2007 10:00:54 PM: Close Connection [1]
9/17/2007 10:00:54 PM: Open Connection [2]
9/17/2007 10:01:26 PM: UPDATE CustomerInfo SET RouteID = @RouteID WHERE cust_id = @cust_id [187] [4]
9/17/2007 10:01:36 PM: Customer Route Changed: [CUST ID:187] to 4
9/17/2007 10:01:55 PM: cmd.ExecuteNonQuery() Returned: 0
9/17/2007 10:01:55 PM: Close Connection [2]
//*************************************************************
-- modified at 22:50 Monday 17th September, 2007
|
|
|
|
|
Is it Access? I've found that the parameters have to be added in the same order they're used.
Try reversing the order of
cmd.Parameters.Add("@cust_id", OleDbType.Integer).Value = nCustID;<br />
cmd.Parameters.Add("@RouteID", OleDbType.Integer).Value = nRouteID;
|
|
|
|
|
PIEBALDconsult:
Yeah it is Access and changing the order of the cmd.Parameters.Add() calls did the trick.
Is there a way to mark this thread as SOLVED?
Thanks !!!
|
|
|
|
|
|
Hi all,
for those of you who have been reading my countless posts on this same question, I think I have solved the problem by binding the database data to the checkedlistbox by using datasource and valuemember properties instead of the other way I was doing it because now the checkedlistbox items now bind by ID. Now in order to make the boxes auto tick depending on the particular employee page I am in(eg.this.EmployeeID), I think all I need help on is this 'if' statement. so far all the boxes are ticking with the following code.
What is the if statement going to be?
<br />
techSkillsCheckListBox2.DataSource = dataSet1.TechnicalSkills;<br />
techSkillsCheckListBox2.DisplayMember = "ProgLanguagesDatabase";<br />
techSkillsCheckListBox2.ValueMember = "TechnicalSkillsID";<br />
<br />
int i;<br />
for (i = 0; i <= (techSkillsCheckListBox2.Items.Count - 1); i++)<br />
{<br />
<br />
<br />
if (FirstnameText.Text.Equals(this.EmployeeID))<br />
{<br />
sql = "Select em.TechnicalSkillsID,t.TechnicalSkills,em.EmployeeID from EmpSkills em, TechnicalSkills t where t.TechnicalSkillsID = em.TechnicalSkillsID and em.EmployeeID = '" + FirstnameText.Text + "'";<br />
<br />
<br />
techSkillsCheckListBox2.SetItemChecked(i, true)<br />
Thank you
Sianny aka Sharny
|
|
|
|