|
|
hello everyone,
how I can insert image to database sqlserver by c# code.
and what the type of image that can save in database sqlserver.
|
|
|
|
|
|
Good day everyone,
I have a problem that I really need someone help.
I have an array of objects that is filled from the content of a text file. One line in ther text file contains name,address and employeeID.
The problem is that I can not compare the employeeID in the object with a given employeeID.
How can I get the value of employeeID out of the the array of objects?
Please help.Thanks much in advance
Employee[] employeeList = new Employee[100];
employeeList = new Employee[100];
EmpFileReader empfile = new EmpFileReader();
employeeList = empfile.readFile();
//getEmployeeID returns ID
if(employeeList[i].getEmployeeID()== employeeID )
System.out.println(employeeList[i]);
eric
|
|
|
|
|
First thing you need to do is that you have to ensure whether readFile() method can parse the value from text file to the employee object.
Once you are sure about readFile(), you can just loop through the array and compare the ID..
eric_tran wrote: Employee[] employeeList = new Employee[100];
employeeList = new Employee[100];
No need to instantiate the array twice. btw.
|
|
|
|
|
Hi Michael,
I'm sure that the array of object has all data pulled from the text file.
I can get the value of employeeID from the array of object, but when I compare with a given string, then it does not work.
for (int i=0; i<noemployees; i++)<br="" mode="hold"> {
if(employeeList[i].getEmployeeID()== "1234" )
System.out.println(employeeList[i]);
}
eric
modified on Sunday, December 30, 2007 6:25:21 AM
|
|
|
|
|
Try to write all id of employees array.. see whether you got all employee ids (including the one that you want to search) or not..
For each(Employee emp in Employees){<br />
Console.WriteLine(emp.ID.ToString());<br />
}<br />
<br />
|
|
|
|
|
hi,
i did a Dll which i use on HTML page.
namespace Control {
public interface myIn
{
}
public partial class UserControl1 : UserControl, myIn
{
public UserControl1() {
InitializeComponent();
}
}
i want to write to a file on the client's computer:
private void button2_Click(object sender, EventArgs e)
{
StreamWriter f = new StreamWriter(@"c:\\myfile.txt", false);
f.WriteLine("test");
f.Flush();
f.Close();
}
when i click this button i get an error message in the browser indicating that an unpremessioned taks took place - and the file is not written.
does anybody know how to write to the clients computer (via this COM object)?
thanks,
Samy
|
|
|
|
|
samy100 wrote: i want to write to a file on the client's computer
It's not allowed to do that for security reason unless the client has added your site in trusted website..
|
|
|
|
|
Hello,
I think your code will going to write the file on the Server. but It is not permitted. Actually this is Server side code. You may test this on other computer(cliant) on LAN, I think it will write on the server where it is reside.
This is the Suggestion. Please reply after test or found solution.
Best of Luck.
Dipak
|
|
|
|
|
it is in Javascript - so it is in the client's computer not the Server side.
|
|
|
|
|
I have a class like this:
class StateManager
{
bool IsLoading { get { ... } }
bool IsValidated { get {... } }
}
- and I want to bind to one of these getters, i.e. pass to some function which of these properties to ask (some time later), like this:
void DoSomething()
{
CheckLater( bind(StateManager.IsLoading));
}
void CheckIt(something property)
{
bool state = unbindAndCallGetter(property);
if (!state)
;
}
Ideally, I don't have to add to StateManager anything (per-property) except the property itself.
bind can get the name of the property as a string, or anything that's simple to type.
unbindAndCallGetter can use reflection (performance-wise it's ok in this situation)
Currently, I am passing a delegate { return StateManager.IsLoading; } , which is flexible but could be shorter, and is not good for diagnostics (knowing in CheckIt that it was "IsLoading" what failed would be immensely useful).
Any other suggesiton welcome - my goal is to simplify syntax and readability.
|
|
|
|
|
I am working on a program in C# the program is like a personal database holds numbers, names, little bit of everything even have a section for calculating and managing my bills. I have pretty much everything done, majority of the code and have the MySql DB finished. The problem I have is I want the information I have in the DB to be pulled and placed in txt boxes. I can pull the info and put it in a DataGrid but that is not what I am wanting to do. I am just having a hard time trying to figure out how to get the DB information to be pulled into the text boxes that I have. I did have this similar program using XML, but I want to take it a step further.
|
|
|
|
|
ok i think i have it now, just need to make some minor alterations, and instead of using a load button i will be using a the Select.Item.Index from a listbox to retrieve the information from the database. if anyone has any comments or notices room for correction please let me know. i enjoy C# but i am new to the combination of C# & MySql.
private void loadBtn_Click(object sender, EventArgs e)<br />
{<br />
string strFindMovie = "SELECT movie_name FROM movie WHERE movie_id='1'";<br />
<br />
MySql.Data.MySqlClient.MySqlConnection conDatabase = new <br />
MySql.Data.MySqlClient.MySqlConnection("Data Source=localhost; Database=moviesite; username=******; password=*****");<br />
MySql.Data.MySqlClient.MySqlCommand cmdDatabase = new <br />
MySql.Data.MySqlClient.MySqlCommand(strFindMovie, conDatabase);<br />
<br />
conDatabase.Open();<br />
<br />
MySql.Data.MySqlClient.MySqlDataReader rdrMovie;<br />
rdrMovie = cmdDatabase.ExecuteReader();<br />
<br />
while (rdrMovie.Read())<br />
{<br />
this.nameTB.Text = rdrMovie.GetString(0);<br />
}<br />
<br />
rdrMovie.Close();<br />
conDatabase.Close();<br />
}
modified on Saturday, December 29, 2007 5:46:14 PM
|
|
|
|
|
shadowhazard wrote:
ok i think i have it now, just need to make some minor alterations, and instead of using a load button i will be using a the Select.Item.Index from a listbox to retrieve the information from the database. if anyone has any comments or notices room for correction please let me know. i enjoy C# but i am new to the combination of C# & MySql.
That sounds like the right thing to do. It's good to see that you solved the problem yourself. Way to go
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Yeah, was stumped at first on how to get it started then it hit me like a ton of brickes and then it fell into place. i use MySql for many things with web development now will be using it for the many database type programs i will be creating.
|
|
|
|
|
It's quite useful to use the try-finally and/or using blocks to ensure that connections etc are closed when some unforseen error occurs in your data handling code.
|
|
|
|
|
 yeah, here is my updated version as of yesterday, again this code is just my sample code i am testing, this is not the DB and such that i will be using in my main program.
string strMovieName = this.movieNameTB.Text;<br />
<br />
try<br />
{<br />
<br />
if (strMovieName == "")<br />
{<br />
MessageBox.Show("You must provide the Movie name");<br />
return;<br />
}<br />
<br />
string strFindMovie = "SELECT * FROM movie WHERE movie_name = '" + strMovieName + "'";<br />
<br />
<br />
MySql.Data.MySqlClient.MySqlConnection conDatabase = new<br />
MySql.Data.MySqlClient.MySqlConnection("Data Source=localhost; Database=moviesite; Persist Security Info=yes; username=*******; password=*****");<br />
<br />
MySql.Data.MySqlClient.MySqlCommand cmdDatabase = new<br />
MySql.Data.MySqlClient.MySqlCommand(strFindMovie, conDatabase);<br />
<br />
conDatabase.Open();<br />
<br />
MySql.Data.MySqlClient.MySqlDataReader rdrMovie;<br />
rdrMovie = cmdDatabase.ExecuteReader();<br />
<br />
while (rdrMovie.Read())<br />
{<br />
this.typeTB.Text = rdrMovie.GetString(2);<br />
this.movieYearTB.Text = rdrMovie.GetString(3);<br />
}<br />
<br />
rdrMovie.Close();<br />
conDatabase.Close();<br />
}<br />
catch (MySqlException ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}
|
|
|
|
|
Hi friends,
I have a homework, i worked for hours but I got stuck in a point. I can't go out of this point.
I am very glad if you can help me.
I make effort to get a query from from northwind database sample. I want max sales of employees according to product.
There are 9 employees(sales persons). There are 77 products type. Salespersons sell this products. I want ,which product was sold maximumly according to sales turnover. The result must be like below
salesperson product sales amount
salesperson1 product a x
salesperson2 product b y
. .
. . .
.
salesperson9 product h w.
I tryed below script, I can find max sales of each salespersons but I can't add productname column to this query.
select t.firstname,t.lastname,max(t.sales) as sales
from (select employees.Firstname,employees.lastname,products.productname,
sum("order details".unitprice*quantity*(1-discount)) as Sales from ((Employees inner join orders on employees.employeeID=orders.employeeID) inner join "order details" on orders.orderID="order details".orderID) inner join products on products.productID="order details".productID
group by employees.lastname,employees.firstname,products.productname
) as t
group by t.firstname,t.lastname
order by t.firstname
Good DAys
Regards
|
|
|
|
|
Are you still having trouble?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Yes, I still can't find solution.
|
|
|
|
|
Don't you need a products.productname in the group by ?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
I need product name of max sold products in result table.
|
|
|
|
|
I want to build a very dynamic program but the thing is i need your help. I am reading the entire xml file on application startup. I want to display my custom Label when user click on the Next button, if user click again i want to display the the custom circle and so on.
Firstly, I don't want to load all the controls when application startsup. I want to separate controls from their data that way i wouldn't be loading those controls which aren't being displayed currently.
Secondly, offcourse any change in the data value should reflect the controls means if X value changes on the dataside so the controls X position value on the screen should changes as well.
Lastly, a very intersting thing i want to implement is that lets say a custom lable control is displayed and changes its position onMouseMove on the stage it should update it's class raw data.
Thanks for ur help
xml
Label
Text Hello World Text
width 10 width
height 15 height
Label
Circle
width 12 width
height 13 cheight
circle
Triangle
width 15 cwidth
height 20 width
Triangle
xml
|
|
|
|
|
hi,
for(i=0;i<4;i++)<br />
{<br />
if(i==0){button.Color=Color.Red;}<br />
else if(i==1){button.Color=Color.Blue;}<br />
else if(i==2){button.Color=Color.Black;}}<br />
else if(i==3){button.Color=Color.Yellow;}}<br />
}
why button color is not change?i want change the button color according to the if-else conditions.
I AM WORKING ON "PLOTTER ROBOT"(FYP).
|
|
|
|