|
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
|
|
|
|
|
The values entered in the UserName TextBox and Password TextBox are compared to the values in the database using the StoredProcedure. And based on that a user is given access to FileManager.aspx or shown an AccessDenied.aspx page. But it does not work that way? I get access to FileManager.aspx page no matter what UserName and Password I put in. Can somebody please tell me what should be the correct code in the Try..Catch method. Cuz that's where my code is wrong. My StoredProcedure works fine. Thanks
protected void btnLogOn_Click(object sender, EventArgs e)
{
SqlConnection sqlconSource = new SqlConnection(ConfigurationManager.AppSettings["cs"]);
SqlCommand sqlcmdSource = new SqlCommand("LogOn", sqlconSource);
sqlcmdSource.CommandType = CommandType.StoredProcedure;
sqlcmdSource.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar, 40));
sqlcmdSource.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar, 10));
sqlcmdSource.Parameters["@UserName"].Value = txtUserName.Text;
sqlcmdSource.Parameters["@Password"].Value = txtPassword.Text;
try
{
sqlconSource.Open();
if (sqlcmdSource.ExecuteScalar().ToString() == "0")
Response.Redirect("AccessDenied.aspx");
}
catch
{
}
finally
{
Response.Redirect("FileManager.aspx");
sqlconSource.Close();
}
And this is my Stored Procedure:
ALTER PROC [dbo].[LogOn]
@UserName varchar(40),
@Password varchar(10)
AS
begin
if exists(select * from UserInformation where UserName = @UserName AND Password = @Password)
begin
select 1 returnflag --UserName is found
end
else
begin
select 0 returnflag--UserName not found
end
end
RETURN
|
|
|
|
|
Finally{} statement will execute no matter what, so you will always redirect to FileManager.aspx.
Also, remove the Catch {} statement if you don't plan to handle any specific exceptions.
|
|
|
|
|
Maybe in that case then I should not use Try..Catch method. What is the other way for me to work with this??
|
|
|
|
|
SqlConnection sqlconSource = new SqlConnection(ConfigurationManager.AppSettings["cs"]);
SqlCommand sqlcmdSource = new SqlCommand("LogOn", sqlconSource);
sqlcmdSource.CommandType = CommandType.StoredProcedure;
sqlcmdSource.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar, 40));
sqlcmdSource.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar, 10));
sqlcmdSource.Parameters["@UserName"].Value = txtUserName.Text;
sqlcmdSource.Parameters["@Password"].Value = txtPassword.Text;
sqlconSource.Open();
if (sqlcmdSource.ExecuteScalar().ToString() == "0")
Response.Redirect("AccessDenied.aspx");
else
Response.Redirect("FileManager.aspx");
sqlconSource.Close();
If you want the Try{} Catch{} because you want to handle a specific SQL exception then do it this way
Try
{
SqlConnection sqlconSource = new SqlConnection(ConfigurationManager.AppSettings["cs"]);
SqlCommand sqlcmdSource = new SqlCommand("LogOn", sqlconSource);
sqlcmdSource.CommandType = CommandType.StoredProcedure;
sqlcmdSource.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar, 40));
sqlcmdSource.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar, 10));
sqlcmdSource.Parameters["@UserName"].Value = txtUserName.Text;
sqlcmdSource.Parameters["@Password"].Value = txtPassword.Text;
sqlconSource.Open();
if (sqlcmdSource.ExecuteScalar().ToString() == "0")
Response.Redirect("AccessDenied.aspx");
else
Response.Redirect("FileManager.aspx");
}
Catch (SqlException e)
{
}
Finally
{
if (sqlconSource.State == ConnectionState.Open)
sqlconSource.Close();
}
|
|
|
|
|
I suggest hashing the password, rather than storing the raw password.
Maybe others have better ideas as well?
|
|
|
|
|
I have a console application running in an infinite loop, it simply parses text files. I need to know how to detect a keypress and then determine which key was pressed. I want the program to terminate upon the pressing of the escape key. Any help would be appreciated, I've been combing the web all over and have found nothing to be helpful.
|
|
|
|
|
ConsoleKeyInfo cki = Console.ReadKey(true);
Console.WriteLine(cki.Key.ToString());
Check the ConsoleKeyInfo.Modifiers collection for the ALT, CTRL, SHIFT keys and you can compare them with the ConsoleModifiers enum.
you can use whatever loop structure you want
do
{
}
while (cki.Key != ConsoleKey.Escape);
You can simply find this information in the MSDN article for Console.ReadKey()[^]
|
|
|
|
|
This will not work. I need to be able to be able to exit at any give time upon the keypress.
|
|
|
|
|
That makes it a little tougher. Which version of .NET are you using? The Console.ReadKey() that Chris suggested is not available until 3.0, unfortunately.
Seems to me that you'll want to make frequent checks for "escape key pressed" within your infinite loop. Some pseudo-code:
while (true)
{
flag = false
get next file
open file
while (not flag)
{
read line from file
if eof
flag = true
else
{
process data from file
if escape key pressed
flag = true
}
}
close file
if flag
exit program
}
The big problem remaining is how to determine if the escape key has been pressed. If you're using 3.0 then Console.ReadKey() should do it. If not, well does it have to be the escape key? The enter key would a lot easier to detect: Console.ReadLine().
BDF
|
|
|
|
|
Iam doing my graduation project and i need to language which is better to dealing with 3d graphics , because i need to build a 3d home from 2d home ( which is drawing by user by this langauge ) and i don't which is better c# or vb.net ??? beacase i need to learn it ...
|
|
|
|
|
Do you have a C/C++/Java background? I'd recommend C#.
Otherwise, I'd say take a few days and play around with both of them and get a feel for the synax because it is different. I'd still recommend C#, but there are solutions for either language.
I've got a book by Apress called "Pro .NET 2.0 Graphics Programming using GDI+. It is pretty good and is a C# book.
Good Luck!
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
For graphics and vector manipulation? You'll tear your hair out trying to use VB.NET for such a thing. Two main reasons:
1. The C# syntax is unambiguous when you're referencing array/matrix/vector indices. In VB.NET, array access and function calls are syntactically identical.
2. Numeric manipulation. VB.NET conceals every rounding, casting, and floating point operation. It tries its best to figure out what you wanted and when precision matters, always gets it wrong unless you're very well versed in the language and know exactly when to cast and when not to.
Obviously either language WILL work for this and depending on your skill level, it may not make any difference. But like the previous poster says - if you've already got a background in C++/Java then C# will be easier to use.
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
|
|
|
|