|
I am totally new on webservice callings.
Can you give me an explicit example? please.
thank you.
|
|
|
|
|
merlinq12 wrote: I am totally new on webservice callings.
Can you give me an explicit example? please.
It's not something you do within a few lines of code.
The w3schools website has a nice explanation on Ajax[^], that should show you how to call a webservice with a variable. You'd also need a webserver to host that webservice - that's where the C# code would run.
I are Troll
|
|
|
|
|
Hello!
I'm using this code to detect the cpu temperature.
But I get the error: "The type or namespace name 'ManagementClass' could not be found (are you missing a using directive or an assembly reference?)", But I think I use all usings I need.
I'm using visual C# 2010
This is my code:
using System;
using System.Windows.Forms;
using System.Management;
namespace Heater
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ManagementClass processClass = new ManagementClass(@"root\WMI:MSAcpi_ThermalZoneTemperature");
foreach (ManagementObject service in processClass.GetInstances())
{
MessageBox.Show("CPU Temperature: " + service.GetPropertyValue("CurrentTemperature"));
}
}
static decimal ConvertToCelsius(string reading)
{
return (decimal.Parse(reading) / 10 - 273.15m);
}
}
}
I want the output to label1, but that's not important now, because the script isn't working.
If I remove all unused usings, system.management is gone too!
Thanks in advance!
PS: sorry for my worse English :/
|
|
|
|
|
I guess you are compiling for "Client profile" and need to compile for the "Full framework".
Philippe Mori
|
|
|
|
|
Ok, but how to that in MS Visual C# 2010?!?
|
|
|
|
|
- Display project properties (from contextual menu)
- Application tab
- Target framework
- Select appropriate target framework.
Client profile is a subset of the full framework that essentially contains classes that are mostly used by regular applications.
Philippe Mori
|
|
|
|
|
|
as the error suggests, you need two things: a using directive (or a heavy duty keyboard and a lot of time) and a reference.
I think you did the using directive yourself, without having the required reference. My advice is:
1.
Take care of the reference first, use Solution Pane, Add Reference; the MSDN doc on the class of interest tells you which one you need.
2.
Once the ref is in place, Intellisense will guide you trough the using directive.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I only can find this, but what do you mean? Do I miss a piece of code?
|
|
|
|
|
and that page says:
Assembly: System.Management (in System.Management.dll)
So add the reference to your project as I told you.
rms123 wrote: Do I miss a piece of code?
No.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Okey! thanks, it's working!
|
|
|
|
|
Luc Pattyn wrote: you need two things: a using statement
No you frackin' don't! 
|
|
|
|
|
Right. Fixed it.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Better... but it's a directive, not a statement. 
|
|
|
|
|
fixed that too. Thanks.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi all
i created a database and table for language and translations
the fileds are like this
<br />
language-><br />
languagename,languagecode<br />
English 101<br />
Hindi 102<br />
<br />
translation-><br />
textinenglish,languagecode,translated<br />
Hellow 101 Hellow<br />
Hellow 102 hindihellow
Now I Have A Combo box in my form and 1 label
I Need To Change label text to the selected language in combobox
so i writed code like this but i dont know how to get the value from database Please Help me
SqlConnection con = new SqlConnection("server=ARUN-09BF105DE8\\AR; initial catalog=prod; integrated security=true");
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
object scode;
scode = comboBox1.SelectedValue;
changelanguage(scode);
}
public void changelanguage(object code) {
con.Open();
SqlCommand com = new SqlCommand();
SqlDataReader dr;
com.Parameters.AddWithValue("language", code);
com.CommandText = "SELECT translated FROM translation WHERE languagecode=@language";
dr=com.ExecuteReader();
}
Trust one who has tried
|
|
|
|
|
If you look here: http://stackoverflow.com/questions/119568/best-practice-to-make-a-multi-language-application-in-c-winforms[^] there is a discussion of the various ways to achieve this. The way you have selected is not necessarily the best: it requires a version of SQLServer to be available to each PC on which your app will run, which may not be possible or desirable.
However:
public void changelanguage(object code) {
con.Open();
SqlCommand com = new SqlCommand();
SqlDataReader dr;
com.Parameters.AddWithValue("language", code);
com.CommandText = "SELECT translated FROM translation WHERE languagecode=@language";
dr=com.ExecuteReader();
while (dr.Read()) {
if ((string) dr["textinenglish"] == theWordIWantToTranslate) {
...
}
}
}
BTW: Please remember that you are responsible for Close-ing and Dispose-ing all of the SQLCommand and SQLConnection objects you create!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Arunkumar.Koloth wrote: AddWithValue("language",
Don't forget the @ .
And, yeah, that doesn't look like the best way to do it.
|
|
|
|
|
can you tell me a good way to do this?
|
|
|
|
|
|
how can we do the database connectivity in c# windows form
|
|
|
|
|
Take your pick:
ADO.NET
Enitiy Framework
LINQ to SQL
nHibernate.
|
|
|
|
|
Keith Barrow wrote: Take your pick
That will only be helpful if he is data mining, surely?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
I've never been accused of being helpful yet
|
|
|
|
|