|
Thanks for your answers. Everything is fine.. Then I there is any possibility to read the sms from nokia pc suite.
|
|
|
|
|
Here a sample[^] for you.
/* LIFE RUNS ON CODE */
|
|
|
|
|
Hello,
I'm having a few issues with my code, i'm following this tutorial http://www.homeandlearn.co.uk/csharp/csharp_s12p6.html Can anyone point me in the right direction. I've included my code below.
The best overloaded method match for 'System.Data.SqlClient.SqlDataAdapter.SqlDataAdapter(string, System.Data.SqlClient.SqlConnection)
<pre lang="c#">Argument 2: cannot convert from 'System.Data.SqlServerCe.SqlCeConnection' to 'System.Data.SqlClient.SqlConnection'
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Game
{
public partial class Form1 : Form
{
public OpenFileDialog dialog = new OpenFileDialog();
System.Data.SqlServerCe.SqlCeConnection con;
System.Data.SqlServerCe.SqlCeDataAdapter da1;
DataSet ds1;
public Form1()
{
InitializeComponent();
}
private void btn_sel_Click(object sender, EventArgs e)
{
dialog.ShowDialog();
MessageBox.Show(dialog.FileName);
loadconnection();
}
private void btn_close_Click(object sender, EventArgs e)
{
Application.Exit();
}
public void loadconnection()
{
con = new System.Data.SqlServerCe.SqlCeConnection();
con.ConnectionString = "Data Source=" + dialog.FileName + "";
con.Open();
ds1 = new DataSet();
string sql = "SELECT * From tbl_games";
da1 = new System.Data.SqlClient.SqlDataAdapter(sql, con);
da1.Fill(ds1, "Name");
con.Close();
}
}
}
|
|
|
|
|
antrock101 wrote: da1 = new System.Data.SqlClient.SqlDataAdapter(sql, con);
You have defined dal to be of type SqlCeDataAdapter .
You cannot assign it to an instance of SqlDataAdapter .
Thus you get an error.
Use one type of data adapter and there should be no error.
|
|
|
|
|
Thank you
I've entered
da1 = new System.Data.SqlServerCe.SqlCeConnection(sql,con);
Which appears to work however it requires a function that contains 2 arguments and i'm not entirely sure what it's trying to reference
|
|
|
|
|
|
I have, but i'm having trouble getting this to work
|
|
|
|
|
And you think we can guess what trouble that is? Please show the exact code you are using and what errors you receive. If you look closely at the link I gave you it shows exactly what parameters are required by the constructor. Have you done it correctly?
|
|
|
|
|
No. You havent done what Abinav suggested to you.
public partial class Form1 : Form
{
public OpenFileDialog dialog = new OpenFileDialog();
System.Data.SqlServerCe.SqlCeConnection con;
System.Data.SqlServerCe.SqlCeDataAdapter da1;
DataSet ds1;
public Form1()
{
InitializeComponent();
}
private void btn_sel_Click(object sender, EventArgs e)
{
dialog.ShowDialog();
MessageBox.Show(dialog.FileName);
loadconnection();
}
private void btn_close_Click(object sender, EventArgs e)
{
Application.Exit();
}
public void loadconnection()
{
con = new System.Data.SqlServerCe.SqlCeConnection();
con.ConnectionString = "Data Source=" + dialog.FileName + "";
con.Open();
ds1 = new DataSet();
string sql = "SELECT * From tbl_games";
da1 = new System.Data.SqlServerCe.SqlCeDataAdapter(sql, con);
da1.Fill(ds1, "Name");
con.Close();
}
}
Try the above modified code.
BTW: are you writing the above program for WindowsCE device?
Jibesh V P
|
|
|
|
|
You're trying to mix and match similarly named classes from System.Data.SqlServerCe and System.Data.SqlClient namespaces. Understand which platform you're targeting and use the appropriate namespace for the platform.
|
|
|
|
|
if (txtdisc.Text ==null)
{
txttot22013 = txtpr22013 + txtpr22014 + txtpr22015 + txtpr22016 + txtpr22017;
Double txtdisc22013 = Convert.ToDouble(txtdisc.Text);
txttot22013 = txttot22013 - txtdisc22013;
txttot.Text = txttot22013.ToString();
}
else
{
txttot22013 = txtpr22013 + txtpr22014 + txtpr22015 + txtpr22016 + txtpr22017;
txttot.Text = txttot22013.ToString();
}
if (txtvat.Text == null)
{
MessageBox.Show("Enter Vat Amount");
}
else
{
Double txtvat22013 = Convert.ToDouble(txtvat.Text);
txtvat22013 = txtvat22013 / 100;
txtvat22013 = txtvat22013 * txttot22013;
Double txtvatinclu22013 = txtvat22013 + txttot22013;
txtvatinclu.Text = txtvatinclu22013.ToString();
}
|
|
|
|
|
There's no loop in that code anywhere. What's your question?
BTW - you shouldn't use Convert.To... to convert doubles - try Double.TryParse instead as it's much more tolerant of invalid values.
|
|
|
|
|
You REALLY need to pick up a beginners book on C# and work through it. There is no loop in any of this code and if statements are not cosidered loops at all.
TextBox.Text will NEVER return null . It's either going to be something that the user typed in or String.Empty , but never null .
|
|
|
|
|
if (txtdisc.Text == null)
{
..
Double txtdisc22013 = Convert.ToDouble(txtdisc.Text);
translates into
Double txtdisc22013 = Convert.ToDouble(null);
That does not make much sense.
|
|
|
|
|
It will never get that far as txtdisc.Text can never be null as it returns a string.
the OP should of tested it either by
if(string.IsNullorEmpty(txtdic.Text) != true)
{
}
or
if(txtdisc.Text != string.Empty)
{
}
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Hi
First, like others mentioned, "if" and "else" are conditional statements, they are not loop.
Second, the textbox will return empty if it has no value assigned to it, so checking for null is redundant.
Third, this is a coding horror!
if (txtdisc.Text ==null) This check is redundant therefore the calls below will never be executed.
{
txttot22013 = txtpr22013 + txtpr22014 + txtpr22015 + txtpr22016 + txtpr22017;
Double txtdisc22013 = Convert.ToDouble(txtdisc.Text); Converting a null to a nullable Double will 0.0;
txttot22013 = txttot22013 - txtdisc22013; (Some value – 0.0)
txttot.Text = txttot22013.ToString();
}
else
{
txttot22013 = txtpr22013 + txtpr22014 + txtpr22015 + txtpr22016 + txtpr22017;
txttot.Text = txttot22013.ToString(); The value of "txttot22013" in the else conditions is no different to the one in if condition.
}
if (txtvat.Text == null)
{
MessageBox.Show("Enter Vat Amount"); This will never be called.
}
else
{
Double txtvat22013 = Convert.ToDouble(txtvat.Text); Possible exception.
txtvat22013 = txtvat22013 / 100;
txtvat22013 = txtvat22013 * txttot22013;
Double txtvatinclu22013 = txtvat22013 + txttot22013;
txtvatinclu.Text = txtvatinclu22013.ToString();
}
If I rewrite your code, it may as follows:
txttot22013 = txtpr22013 + txtpr22014 + txtpr22015 + txtpr22016 + txtpr22017;
txttot.Text = txttot22013.ToString();
if (string.IsNullOrEmpty(txtvat.Text))
{
MessageBox.Show("Enter Vat Amount");
}
else
{
double txtvat22013;
if (Double.TryParse(txtvat.Text, txtvat22013))
{
Double txtvatinclu22013 = (txtvat22013 * txttot22013 / 100) + txttot22013;
txtvatinclu.Text = txtvatinclu22013.ToString();
}else
{
MessageBox.Show("Enter Valid Vat Amount");
}
}
Regards
Jegan
|
|
|
|
|
thanks a lot for suggestion but "loop" is my mistake i knw its a conditional statements ... thanks a lot for every one coz ur my seniors u have rights correct me....
|
|
|
|
|
Does that include correcting your English that you typed?
|
|
|
|
|
Hi All,
How to run the schedule task from .NET application?
Thanks in advance.
|
|
|
|
|
You're going to have to be a bit more specific than that. Since we're not sitting right next to you, we can't tell what your eyes were looking at and what your finger was pointing at when you said "How do I run that?"
Are you talking about Windows Task Scheduler? Some task in an application? Some task setup on a remote server?
|
|
|
|
|
Hi Dave,
I have an exe file which is placed in scheduler Tasks(Control Panel--->Scheduled Tasks). I need to have a dotnet program which should run this scheduler automatically from my program.
The above scheduled task is installed on my machine.
|
|
|
|
|
There's a bit of a problem. There are TWO Task Schedular APIs. I can't remember the exact deatils, but tasks created in one API cannot be seen in the other. So, if you app uses one API and you can't see the task you want, you'll have to rewrite against the other API.
|
|
|
|
|
Take a look at the Task Scheduler API: http://msdn.microsoft.com/en-us/library/aa383614.aspx
|
|
|
|
|
how to store images from imagelist\listview to spacific folder in c#
|
|
|
|
|
usually, something like
Bitmap b = new Bitmap(this.imageList1.Images[0]);
b.Save(@"Drive:\path\image-file-name.bmp");
"imageList1" obviously depends on what your Image List is called
|
|
|
|