|
Hello guys, Jun, Christian
Well, why don't we help the newbies with code snippets? This would encourage them, and give them a head start, wouldn't it?
I mean.. Is it "cheating" if we help them with a line or two, just as an assistance in their projects? I don't endorse it as a habit, yet I think they sometimes deserve more help than mere general guidance don't you agree?
Regards
|
|
|
|
|
Yes, by all means. We should help those who have tried, not those who just pass the assignment to us.
Best,
Jun
|
|
|
|
|
Well, it sounds fair enough for me.
Thanks Jun.
Regards
|
|
|
|
|
x2pca wrote: Please help me with the code since i have to deliver my application by tomorrow evening.
Yeah right!!
If you're a student, get used to the fact that nobody is going to do your job for you. Nobody.
If you are already in the industry, why have you not figured that out yet?!?!?!?!?!
Good luck. The clock is ticking...
:josh:
My WPF Blog[^]
|
|
|
|
|
hi,
I create a dataset and fill it with access database. everything is fine, I can see the data in the binded grid control. but i have an exception when I do the copy operation. the exception says, the dataset can not pass the constrains (non null, foreign key...).
I think I can not create the first dataset if the data is wrong?
does anyone have idea about this?
Thanks a lot!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
DataTable has two methods, BeginLoadData and EndLoadData, which can be used when copying data into the table to prevent constraints from being enforced temporarily. Try using those when copying the data.
:josh:
My WPF Blog[^]
|
|
|
|
|
I am coding a interest calculator in C# using Visual Studio 2005 Express edition and I keep on getting the following error: "CalcBalance does not exist in the current context". I am not sure what's cuasing it or how to fix it. Any advice which would help in get this code working would be greatly appreciated. Below is the full code:
<%@ Control Language="C#" ClassName="WebUserControl" %>
protected void Button1_Click(object sender, EventArgs e)
{
Label6.Text = "Final Balance: $" +
CalcBalance(Convert.ToInt32(TextBox1.Text),
(Convert.ToInt32(TextBox2.Text) / 100),
Convert.ToInt32(TextBox3.Text),
Convert.ToInt16(DropDownList1.SelectedItem.Value)).ToString();
}
private string CalculateBalance(int Principal, double Rate, int Years, int Period)
{
double result;
double NumToBeRaised = (1 + Rate / Period);
result = Principal * System.Math.Pow(NumToBeRaised, (Years * Period));
return (result.ToString("C"));
}
<asp:label id="Label1" runat="server" style="position: relative" text="Compound interest Calculator" width="318px" font-bold="True" font-size="Large">
<asp:label id="Label2" runat="server" style="position: relative" text="Principal ($)" width="165px">
<asp:textbox id="TextBox1" runat="server" style="position: relative">
<asp:label id="Label3" runat="server" style="position: relative" text="Rate (%)" width="165px">
<asp:textbox id="TextBox2" runat="server" style="position: relative">
<asp:label id="Label4" runat="server" style="position: relative" text="Years:" width="165px">
<asp:textbox id="TextBox3" runat="server" style="position: relative">
<asp:label id="Label5" runat="server" style="position: relative" text="Compound Frequency:" width="165px">
<asp:dropdownlist id="DropDownList1" runat="server" style="position: relative">
<asp:listitem value="1">Annually
<asp:listitem value="4">Quarterly
<asp:listitem value="12">Monthly
<asp:listitem value="365">Daily
<asp:listitem>
<asp:button id="Button1" runat="server" style="left: 9px; position: relative; top: 10px"
="" text="Calculate" width="207px" onclick="Button1_Click">
<asp:label id="Label6" runat="server" style="position: relative" width="165px">
Greg
The Belizean Dan Dada!!!
|
|
|
|
|
Are you kidding?
You are calling a function named CalcBalance but you have defined one with the name CalculateBalance . Do you see the difference?
|
|
|
|
|
protected void Button1_Click(object sender, EventArgs e)
{
Label6.Text = "Final Balance: $" +
CalcBalance(Convert.ToInt32(TextBox1.Text),
^^^^^^^^^^^ -- LOOK AT WHAT YOU TYPED HERE :~
(Convert.ToInt32(TextBox2.Text) / 100),
Convert.ToInt32(TextBox3.Text),
Convert.ToInt16(DropDownList1.SelectedItem.Value)).ToString();
}
private string CalculateBalance(int Principal, double Rate, int Years, int Period)
^^^^^ - NOW LOOK AT WHAT YOU TYPED HERE :omg:
{
double result;
double NumToBeRaised = (1 + Rate / Period);
result = Principal * System.Math.Pow(NumToBeRaised, (Years * Period));
return (result.ToString("C"));
}
|
|
|
|
|
By looking at your code, it seems as CalculateBalance(...) is the function that actually calculates the interest but you are using CalcBalance instead of CalculateBalance(...) as the name of the function.
If the name of the interest calculating function is actually CalcBalance, then this error might be because CalcBalance is not in the current class.
Regards,
Wasif Ehsan
|
|
|
|
|
wasife wrote: If the name of the interest calculating function is actually CalcBalance, then this error might be because CalcBalance is not in the current class.
"this error might be..." You are too kind, Wasif
:josh:
My WPF Blog[^]
|
|
|
|
|
Thanks, Guys I really apprecaite the tip. I changed the name and it worked. This code was written directly from a microsoft book, as is, so i took it for granted that i was doin something wrong................what a dork. Thanks again. I knew I can rely on you guys for assistance.
Greg
The Belizean Dan Dada!!!
|
|
|
|
|
Which just goes to proove:
1) Technical writers/editors make mistakes too
2) Dont believe everything you read without verifying it
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
Hi, i'm trying to show the "video capture filter" or "video source" form to configure the webcam parameters.
How can i do that??
Very thanks. Sorry, I'm Spanish.
www.studios-tortuga.com
|
|
|
|
|
You probably should begin by reading Chris' article on how to get answers to your questions. It is really unclear as to what you are asking here! If you believe there is some kind of dialog in .NET to display this video source form, you are very wrong. You will have to write this yourself. If it is a feature within a webcam piece of hardware, then you need to look into the webcam SDK and determine how to interact with this in your program. Contacting the webcam manufacturer will help along these lines.
|
|
|
|
|
It's ok to be Spanish. Don't apologise. Now, if you were Welsh....that's a different question.
Regards
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
I’m having troubles with the following code:
txtSelect.Text = “Select System_id From [DFIParmsHTS].[docsadm].[ExtGroup] where CustNumber = _CustomerNumber”
OdbcCommand cmdSelect= new OdbcCommand(txtSelect.Text, conn);
cmdSelect.CommandType=CommandType.Text;
cmdSelect.Parameters.Add("_CustomerNumber", vfx.TNM);
dr = cmdSelect.ExecuteReader();
Throws SQLSRV32.DLL - ERROR [42S22] [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name '_CustomerNumber'
No kidding _CustomerNumber is an Invalid Column name. I’m trying to replace it with vfx.TNM. If I look at the Command object in the watch window Parameters.items[0].parametername = “_CustomerNumber” and Parameters.items[0].Value = “000122”
So why isn’t it getting to the db that way.
I’ve also tried
txtSelect.Text = “Select System_id From [DFIParmsHTS].[docsadm].[ExtGroup] where CustNumber = @CustomerNumber”
OdbcCommand cmdSelect= new OdbcCommand(txtSelect.Text, conn);
cmdSelect.CommandType=CommandType.Text;
cmdSelect.Parameters.Add("@CustomerNumber", vfx.TNM);
dr = cmdSelect.ExecuteReader();
Throws SQLSRV32.DLL - ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare the variable '@CustomerNumber'
So to me it looks like the Command isn’t committing the changes of the parameters to the query. That made me try:
txtSelect.Text = “Select System_id From [DFIParmsHTS].[docsadm].[ExtGroup] where CustNumber = @CustomerNumber”
OdbcCommand cmdSelect= new OdbcCommand(txtSelect.Text, conn);
cmdSelect.CommandType=CommandType.Text;
cmdSelect.Parameters.Add("@CustomerNumber", vfx.TNM);
cmdSelect.Prepare();
dr = cmdSelect.ExecuteReader();
And that didn’t work either.
Any help is appreciated, Thanks.
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
First question would be why are you using OdbcCommand rather than SqlCommand? It appears you are connecting to a Sql Server database.
|
|
|
|
|
Well some sites use MS SQL others use Postgrsql. When you write code that is flexible and not just MS you can't always take the easy way.
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
True enough. You didn't mention anything about the databases you were using. From the evidence you provided it seemed only SQL Server.
You might want to look at the Microsoft Enterprise Library and the Data Application block to assist in writing a more generic data access layer.
|
|
|
|
|
Thanks for the link. I need all the help i can get with this two DBS thing.
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
|
Parameters in ODBC don't have names. Use "?" in the query to identify the parameters, and add the parameters to the parameter collection in the same order as they appear in the query.
---
b { font-weight: normal; }
|
|
|
|
|
Cool Thanks for the help. I Guess I'm going to just to Replace() on the input string then. The attraction of using parameters was that it allowed a bit of latitude in how the sql strings where made.
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
HahnTech wrote: I Guess I'm going to just to Replace() on the input string then.
Why? Just use '?'
Select System_id From [DFIParmsHTS].[docsadm].[ExtGroup] where CustNumber = ?
then
cmdSelect.Parameters.Add("", vfx.TNM);
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|