|
Hello,
I have created a C# application that calling the stored procudure in MS Access DB file.
Here's the sql for stored procedure called procs_BestMark:
"PARAMETERS startDate DateTime, endDate DateTime;
SELECT Max(Marks) AS Expr1
FROM Students
WHERE (((Students.ExamTime) Between [startDate] And [endDate]));"
Here's my code in C# to call the stored procedure after connected the MS Access DB successfully:
"
odbcnStudentStatus.Open();
odbCommand = new OleDbCommand("procs_BestMark", odbcnStudentStatus);
odbCommand.CommandType = CommandType.StoredProcedure ;
odbCommand.CommandText = "exec procs_BestMark ?, ?";
OleDbParameter paraSD = this.odbCommand.Parameters.Add("startDate",OleDbType.DBDate);
paraSD.Value = new DateTime(2000,1,1);
OleDbParameter paraED = this.odbCommand.Parameters.Add("endDate",OleDbType.DBDate);
paraED.Value = new DateTime(2006,1,1);
int max = (int)this.odbCommand.ExecuteScalar();
"
It throws an error: "oleDBException: Expected query name after EXECUTE."
What is that? I think I have assigned the name of the stored procedure successfully.
Please help!
Thanks
|
|
|
|
|
|
I'm a newbie to control design in C#.
I want to have a .Tag property on all controls or at least a ResourceID property. Can I just inheirit from the base control and extend a new property while keeping all functionality from the original control. Please don't tell me to just find it on the internet, but maybe a real simple example.
Thank you
Fear is the mind killer.
|
|
|
|
|
Wackatronic1 wrote:
I want to have a .Tag property on all controls
Erm, Tag is already a property of Control, so there's no need to derive from it. And, if you want to add a property that is available to all controls, you're MUCH better off implementing it using the IExtenderProvider interface, like the way the ToolTip class works. (And yes, for IExtenderProvider, I'm going to tell you to read the documentation )
The advantage with IExtenderProvider is that you can still use the controls in the designer, and the new property shows up when you drop your extender provider onto the form.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Hi,
I populate a CheckedListBox with a DataTable:
checkedListBox1.DataSource = myDT;
checkedListBox1.DisplayMember = "Name";
checkedListBox1.ValueMember = "ID";
I was wondering if it's possible to get the SelectedValue of every checked (or even selected) item with some sort of loop?
Ron
|
|
|
|
|
|
Hi Yulianto,
Thanks for the link (sorry, I'm a new programmer)...
I've been to that web page before and couldn't figure out from it
how to access the ValueMember data from it.
It only shows how to access the index or text of each item.
The checkedListBox1.CheckedItems object does not seem to include the ValueMember of each item.
thanks,
Ron
|
|
|
|
|
myNameIsRon wrote:
how to access the ValueMember data from it.
What do you mean with ValueMember ?
<italic>Work hard, Work effectively.
|
|
|
|
|
Hi Yulianto,
You can set a ValueMember to each item in a listbox/checkedlistbox by
using a DataTable to populate (Name,ID are column headers).
checkedListBox1.DataSource = myDataTable;
checkedListBox1.DisplayMember = "Name";
checkedListBox1.ValueMember = "ID";<--------
You can get the ValueMamber data of one selected item by using:
checkedListBox1.SelectedValue;
This works fine if you have just one item selected... but what
if you want to loop through every selected item and get the
ValueMember?
thanks,
Ron
|
|
|
|
|
foreach(object itemChecked in checkedListBox1.CheckedItems)
You will get the object, you need to convert it to CheckedListBox
((CheckedListBox)itemChecked ).ValueMember
<italic>Work hard, Work effectively.
|
|
|
|
|
Hi , I have a checked listBox control , which stores multiple items.The thing is , I should store these values and then retrieve.How could I store these values in a SqlColumn ?
( I am sorry it could be an Sql Forum question but there could be a way using C# before Sql, so I decided to post it here.)
Thanks a lot.
Bahadir Cambel.
|
|
|
|
|
Bahadir Cambel wrote:
How could I store these values in a SqlColumn ?
Well, it seems to me you want more than one column. If you want to put all the fields of a checked item in the ListBox control into one column, then you should probably put them into a comma delimited string first.
In either case, put your data into SqlParameters, like:
SqlParameter param=new SqlParameter("@foo", myFooValue);
Then add the parameter:
cmd.Parameters.Add(param);
Then do the ExecuteNonQuery call.
Of course, I'm leaving out the creation of the SqlCommand cmd variable and some other stuff, but that's not relevant to your question.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Thanks for the reply Marc, I thought in the same way , but I asked for that there may be a better solution.
What about putting values into a class/struct,and then serialize it binary and put into a binary column ? Do you have any ideas ? Is it possible ? and could it be more efficient ?
|
|
|
|
|
Bahadir Cambel wrote:
What about putting values into a class/struct,and then serialize it binary and put into a binary column ?
You could do that, but you may encounter, at some point, the need to query the DB, and then you don't have very searchable data.
Also, beware of the .NET binary formatter. It isn't very efficient. It encodes into hideous xml, actually! You'd have to do your own binary serialization if you want efficiency, but then again, you should probably rely on the server to keep things efficient, imo.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Thanks a lot for the replies Marc.
|
|
|
|
|
I want to be able to change the html code at certains points in a aspx page using a code-behind page. For example:
<TD vAlign="bottom" align="left" colSpan="2" height="38">
<DIV align="right"><A href="signup.aspx"><IMG height="38" src="images/gen_header_r1_c1.gif" width="142" border="0"></A><A href="trips.aspx"><IMG height="38" src="images/gen_header_r1_c2.gif" width="133" border="0"></A><A href="guides.aspx"><IMG height="38" src="images/gen_header_r1_c3.gif" width="130" border="0"></A><A href="forums.aspx"><IMG height="38" src="images/gen_header_r1_c4.gif" width="135" border="0"></A><A href="products.aspx"><IMG height="38" src="images/gen_header_r1_c5.gif" width="122" border="0"></A><A href="invite.aspx"><IMG height="38" src="images/gen_header_r1_c6.gif" width="126" border="0"></A></DIV></TD>
I want to be to do this:
<TD vAlign="bottom" align="left" colSpan="2" height="38"><DIV align="right">
<b>GET HTML CODE FROM CODE-BEHIND PAGE</b>
</DIV></TD>
Any help of in the right direction would be appreciated.
Thanks
|
|
|
|
|
You can just put:
<td vAlign="bottom" align="left" colSpan="2" height="38">
<%=SomeMethod()%>
</td>
and in your code behind have:
public string SomeMethod()
{
return "this is a text that is dynamically generated";
}
|
|
|
|
|
Hi,
How can I implement a selection tool that is used to select a part of an image like the one in paint, photoshop or any..
I want the simplest way..;P
Regads..
|
|
|
|
|
There's a few CP articles you can look at. Search google with:
rubberband C# site:codeproject.com
and you'll find more.
Here's one.[^]
A more complicated one.[^]
The second one, while not on the topic you are asking about, includes: "drawing rectangles with a rubberbanding like effect in Paintbrush" and perusing the code should get you on the right track.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Thank you very much. I will try those...
Thank you again
|
|
|
|
|
I'm looking for a C# program that prompts the user for an hourly rate and the number of hours worked. It should compute the gross pay rate, withholding tax and net pay. The withholding tax is computed as a percentage of gross pay based on:
Gross Pay <or= 300="" is="" 10%="" withholding
gross="" pay=""> 300 is 12% withholding
Please can any one let me know if they have a C# program for this
|
|
|
|
|
diabolusgorgon wrote:
Please can any one let me know if they have a C# program for this
This is a 5 minute exercise using the Visual Studio designer. But I guess it must quite the stumper of a homework problem, eh?
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Lol
Kev
|
|
|
|
|
Hello gurus,
I'd like to know how I can delete multiple selected items from a listbox?
Thanks.
Best regards.
There is no spoon.
|
|
|
|
|
bouli wrote:
Hello gurus,
Hey there.
bouli wrote:
I'd like to know how I can delete multiple selected items from a listbox?
One at a time?
Of course, the guru part of me insists on providing a more complete answer. Delete from the last index to the first, so the indexes of the items don't have to be recalcuated when you delete items from the list.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|