|
Write a C# program to add the values of two integer variables, then
display the result with an appropriate message.
|
|
|
|
|
int a = 1;
int b = 2;
Console.Write("{0} + {1} might be equal to {2}", a, b, a + b);
I know homework is boring, but you won't learn much if I just give you the answer.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
i know thank soooooo much.
|
|
|
|
|
becky suinner wrote: i know thank soooooo much.
You're cheating when you should be workin'. You'd better do your homework next time and learn the syntax of Console.WriteLine , because those kind of questions are often ignored here. There ain't no free lunches out there.
Google for 'MSDN Console WriteLine', and bookmark the thing called documentation; it might be your bread and butter one day.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
i also need samples of winsforms or videos cos i tired deminoid.me dont think its functioning anymore.plssssssss
|
|
|
|
|
becky suinner wrote: i also need samples of winsforms or videos cos i tired deminoid.me dont think its functioning anymore.plssssssss
Drop the textspeak, and step into the land of adults
The documentation also contains video's[^], from the "How do I" department.
What is a deminoid[^]?
becky suinner wrote: plssssssss
If you want to be taken seriously, then don't repeat a character more than twice.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Start with these tutorials[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
That is one of the most trivial applications you could write. The fact you could not manage it suggests that you need to buy this[^] book.
If we tell you how to solve your homework, it isn't helping you to learn how to code. If you want to do this professionally, you have to learn how to do this for yourself.
|
|
|
|
|
private void button4_Click(object sender, EventArgs e)
{
mycon.con.Close();
mycon.adp = new SqlDataAdapter("delete from Inquiry_management where Inquiry_ID='" +listBox1.SelectedIndex + "'", mycon.con);
mycon.adp.Fill(ds, "Inquiry_management");
mycon.con.Open();
mycon.con.Close();
listBox1.Update();
MessageBox.Show("Row Deleted");
}
|
|
|
|
|
There is no need to data Adapter , see this :
System.Data.SqlClient.SqlConnection sqlConnection1 =
new System.Data.SqlClient.SqlConnection("YOUR CONNECTION STRING ");
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = "delete from Inquiry_management where Inquiry_ID='" +listBox1.SelectedIndex + "'";
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
cmd.ExecuteNonQuery();
sqlConnection1.Close();
|
|
|
|
|
it doesn't work because i am using the class method;
this is my class coding.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
///
/// Summary description for mycon
///
namespace WindowsFormsApplication1
{
class mycon
{
public static int x = 0;
public static SqlConnection con=new SqlConnection("Data Source=DRONAVAT-PC\\SQLEXPRESS;Initial Catalog=InventoryControl;Integrated Security=True");
public static SqlCommand cmd;
public static SqlDataReader dr;
public static SqlCommandBuilder cd;
public static SqlDataAdapter adp;
public static void enable()
{
}
public static void disable()
{
}
}
}
|
|
|
|
|
hi , i have a little problem here , i have a datagridview that has a plenty of rows and all of that rows are filling with persian words like ("مثلا یه چیزی") , when i'm trying to print this datagridview using printPreviewDialog + print document , it show me the words in wrong spelling . that mean if im seen this word ("محمد") in datagridview it'll print it like this one ("دمحم").
it print it inverse . i have used itextsharp and it also dosnt support persian language .
so any idea ?
|
|
|
|
|
mohammadkaab wrote: it print it inverse
Inverse? You mean from right to left? Most of us can't read Arabic, might be handy to have an English example.
Could you try the setting the RightToLeft[^] property and see if it helps?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
It is printing in reverse the OP's example, "Muhammed" is doing the equivalent of:
"mhmd" is displaying as "dmhd"
I've left the vowels out in the above, as these are written as diacritic marks over/under the main characters for [short] vowels and are customarily left out for most texts. The irony is, I can't speak any other European languages except some schoolboy French and German. Oh and some words in Norwegian, Danish and Dutch are the same as the dialect of English that I speak.
|
|
|
|
|
Keith Barrow wrote: "mhmd" is displaying as "dmhd"
..and where did that extra 'd' come from? Too busy making a point to be correct, are we?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Have you set the RightToLeft property to true? IIRC you will get exactly the problems you describe (the letters being displayed in the reverse order) if you don't. If you can, set the property in the designer, not code.
I'm not sure about the print dialog, the RTL support in winforms is pretty poor.
|
|
|
|
|
couple hours ago , i had download the Spire.DataExport components , it work fine ,but i have a littile problem init , when i want to show my datatable Rows in Pdf it Show It Like this ???? like qustion mark , why ?
the language im using is persian and it's very close to Arabic language , the words is sth like this ("محمد کعب") and it show it like this ("???? ???").
even i have set the property of encoding to UTF8 but nothing happend , just gave me a strange words like this (Ù…ØÙ…).
|
|
|
|
|
You might be having a problem with two different encoding standards. Windows uses a standard for Arabic called Windows-1256. Farsi might be in the same standard. When it is displayed as UTF8 it displays as you describe, with accented characters. You'll need to either encode as UTF8 from Windows 1256 or just set the encoding to windows 1256.
You can see what I mean a bit better here http://forums.digitalpoint.com/showthread.php?t=537748[^]
|
|
|
|
|
I try to find a solution from many places, but not yet solved...and hence I have a
different issue for update dbf file [free table -vfp] from C# OleDbDataAdapter.
string MyConStr = "Provider=VFPOLEDB.1; Data Source='C:\\Temp'; Persist Security Info=False";
VFPDAp = new OleDbDataAdapter();
VFPDAp.InsertCommand = new OleDbCommand();
VFPDAp.UpdateCommand = new OleDbCommand();
VFPDAp.InsertCommand.CommandText = "insert into my_table1 (my_time,reminder) values(?, ?, ?)";
VFPDAp.UpdateCommand.CommandText = "update my_table1 set my_time=?, reminder=? where sl_no=? ";
VFPDAp.InsertCommand.Connection = OleCon1;
VFPDAp.UpdateCommand.Connection = OleCon1;
OleDbParameter Par1 = new OleDbParameter("my_time", -1);
Par1.DbType = DbType.String;
Par1.SourceColumn = "my_time";
Par1.ParameterName = "my_time";
OleDbParameter Par2 = new OleDbParameter("reminder", -1);
Par2.DbType = DbType.String;
Par2.SourceColumn = "reminder"; Par2.ParameterName = "reminder";
OleDbParameter Par3 = new OleDbParameter("my_time", -1);
Par3.DbType = DbType.String;
Par3.SourceColumn = "my_time";
Par3.ParameterName = "my_time";
OleDbParameter Par4 = new OleDbParameter("reminder", -1);
Par4.DbType = DbType.String;
Par4.SourceColumn = "reminder";
Par4.ParameterName = "reminder";
VFPDAp.InsertCommand.Parameters.Add(Par1);
VFPDAp.InsertCommand.Parameters.Add(Par2);
VFPDAp.UpdateCommand.Parameters.Add(Par3);
VFPDAp.UpdateCommand.Parameters.Add(Par4);
OleCon1.ConnectionString = MyConStr;
OleCon1.Open();
VFPDAp.Update(VfpTbl);
OleCon1.Close();
Thanks For The Helps
|
|
|
|
|
Your update-command has three question marks (parameters), yet you assign only two. s1_no isn't added, and will be required.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks Eddy.
While posting time unchecked, but my original code is
VFPDAp.InsertCommand.CommandText = "insert into my_table1 (my_time,reminder) values(?, ?)";
VFPDAp.UpdateCommand.CommandText = "update my_table1 set my_time=?, reminder=? where reminder=? ";
But showing the same error,
SQL: Column 'Q0P2' is not found
Thanks Again
|
|
|
|
|
Paramu1973 wrote: "update my_table1 set my_time=?, reminder=? where reminder=? ";
Same answer still; you have 3 question-marks in there. That means that a IDbCommand will expect three parameters. It will fail if you only supply 2. From the previous code, it looks as if the primary key is missing.
"Which" record would the statement update? You'll either have to remove the condition (in which case "ALL" records will be updated, which is prolly false) or supply the third parameter.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hi Eddy,
Thanks.......you cleared my 1 1/2 days headache...
Thousands of thanks to you....
Really, I become very upset because of that crazy error...
Thanks Again
|
|
|
|
|
Glad I could help a bit
|
|
|
|
|
The other day I have asked a question about a program which sits in a place where images come and once its started, function is that it updates when a new image is added, I have found a relevant code for this but I would like to know that would this do the desired task which I require. Appreciate any assistance.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foundation;
using System.IO;
using System.Data.SqlClient;
using System.Data;
using System.Threading;
using WindowsFormsApplication1;
namespace HotFolderLoader
{
class Program
{
//private BaseFuncs theBaseFuncs = new BaseFuncs();
static void Main(string[] args)
{
string tt = System.Environment.MachineName;
Foundation.BaseFuncs theFoundation = new BaseFuncs();
if (tt == "NEO") //devel
{
//Foundation.getConstr.initialize("Data Source=neo\\neosqlserver;Initial Catalog=nmcvisualdb;Persist Security Info=True;User ID=sa;Password=xxxxxx");
Foundation.getConstr.initialize("Data Source=xx.xxx.xxx.xxx\\bcwebsql;Initial Catalog=nmcvisualdb;Persist Security Info=True;User ID=sa;Password=mr2BCweb");
//Foundation.getConstr.initialize("Data Source=xxx.xx.xxx.xxx\\nmcsql;Initial Catalog=nmcvisualdb;Persist Security Info=True;User ID=sa;Password=xxxxx");
}
else
{
Foundation.getConstr.initialize("Data Source=xx.xxx.xxx.xxx\\bcwebsql;Initial Catalog=nmcvisualdb;Persist Security Info=True;User ID=sa;Password=xxxxx");
}
//CCaseObject gg = new CCaseObject("test1-lil");
int idx = 0;
while (true)
{
System.Console.WriteLine("Starting");
doWork();
idx++;
System.Console.WriteLine("parsing: " + idx.ToString());
Thread.Sleep(80 * 1000);
}
}
public static void doWork()
{
BaseFuncs theBaseFuncs = new Foundation.BaseFuncs();
//D:\Google Drev\CloudHotFolder
//E:\google-drive\Google Drive\CloudHotFolder
DirectoryInfo dirInfo = new DirectoryInfo(@"D:\Google Drev\CloudHotFolder");
//DirectoryInfo dirInfo = new DirectoryInfo(@"E:\google-drive\Google Drive\CloudHotFolder");
FileInfo[] files = dirInfo.GetFiles("*.jpg");
string caseno = "";
string imageType = "";
string previousCaseno = "";
int i = 0;
System.Console.WriteLine("files: " + files.Count().ToString());
while (i < files.Count())
{
FileInfo fileItem = files[i];
bool nameOK = true;
bool isError = fileItem.Name.Contains("Error");
string[] fileData = fileItem.Name.Split('#');
if (fileData.Length < 2)
{
nameOK = false;
}
else
{
caseno = fileData[1];
imageType = fileData[2];
}
System.Console.WriteLine("parsing file: " + fileItem.FullName);
/*
* photo_org = 1,
floor_plan_org = 2,
Panorama_360 = 3,
photo_stage_2 = 4,
floor_plan_stage_2 = 5,
photo_thumbnail = 6,
Panorama_360_stage_2 = 7,
photo_final = 8,
floor_plan_final = 9,
Panorama_360_final = 10,
deleted = 11,
junk = 12,
visual_tour_org = 12,
visual_tour = 13
* */
string imgtypeid = "";
bool typeOK = true;
bool caseOK = true;
switch (imageType)
{
case "1":
case "4":
imgtypeid = "4"; //photo stage 2
break;
case "2":
case "5":
imgtypeid = "5"; //floor plan stage 2
break;
case "3":
case "7":
imgtypeid = "7";
break;
default:
typeOK = false;
break;
}
string sql = "select count(id) from cases where caseno ='" + caseno + "'";
string casecount = theBaseFuncs.doSQLScalar(sql);
if (casecount != "1")
{
caseOK = false;
}
if (typeOK && !isError && caseOK && nameOK)
{
try
{ //(expiryDate - DateTime.Now).Days < 30
if ((DateTime.Now - fileItem.LastAccessTime).Minutes > 1 && fileItem.Length > 10)
{
//check if filename exists
string checkSql = "select count (id) from images where case_id=" + theBaseFuncs.getCaseIDByCaseNo(caseno) + " and image_name='" + fileItem.Name + "'";
int count = Convert.ToInt16(theBaseFuncs.doSQLScalar(checkSql));
if (count > 0)
{
//delete image in db - and then normal upload new version
System.Console.Write("Deleting " + fileItem.Name + "in DB");
string delImages = "delete from images where case_id=" + theBaseFuncs.getCaseIDByCaseNo(caseno) + " and image_name='" + fileItem.Name + "'";
theBaseFuncs.doSQLnonQuery(delImages);
System.Console.Write("...Done");
}
int picID = theBaseFuncs.saveIMG2DB(fileItem, fileItem.Name, "image/jpeg", caseno, imgtypeid, 5, false);
SqlConnection connection = new SqlConnection("Data Source=xx.xxx.xxx.xxx\\bcwebsql;Initial Catalog=nmcvisualdb;Persist Security Info=True;User ID=sa;Password=xxxxx");
System.Drawing.Image img = System.Drawing.Image.FromFile(fileItem.FullName);
//System.Drawing.Image thumbImg = createHQThumb(fullImg, xparm);
string strSql = "UPDATE Images set Image_Data_Thumb=@imagedata ";
strSql += "where id=@picid";
SqlCommand updatecmd = new SqlCommand(strSql, connection);
updatecmd.CommandType = CommandType.Text;
SqlParameter pImg = new SqlParameter("@imagedata", SqlDbType.Image);
pImg.Value = BaseFuncs.imageToByteArray(BaseFuncs.createHQThumb(img, 600));
img.Dispose();
updatecmd.Parameters.Add(pImg);
SqlParameter pPicid = new SqlParameter("@picid", SqlDbType.Int);
pPicid.Value = picID;
updatecmd.Parameters.Add(pPicid);
connection.Open();
updatecmd.ExecuteNonQuery();
fileItem.Delete();
connection.Close();
//System.Console.WriteLine("counter: i=" + i.ToString() + " max=" + files.Count().ToString());
}
if (caseno != previousCaseno || i == files.Count() - 1) //do target check
{
if (i == files.Count())
{
System.Console.WriteLine("swapping caseno - lastfile in list!");
previousCaseno = caseno;
}
System.Console.Write("Making target check case: " + previousCaseno);
theBaseFuncs.logStatus(theBaseFuncs.getCaseIDByCaseNo(caseno), 3, 36, "Hotfolder target check");
if (theBaseFuncs.targetImgCheck(previousCaseno) == 1 && theBaseFuncs.targetPlanCheck(previousCaseno) == 1)
{
System.Console.Write("...target match");
Foundation.CCaseObject theCase = new Foundation.CCaseObject(previousCaseno);
theBaseFuncs.logStatus(theCase.CaseID, 3, 36, "Hotfolder target OK");
theCase.sendToNaming();
System.Console.Write("...case sent!!!!!!!!\n");
}
else
{
theBaseFuncs.logStatus(theBaseFuncs.getCaseIDByCaseNo(caseno), 3, 36, "Hotfolder target not OK");
System.Console.Write(".no match!\n");
}
}
previousCaseno = caseno;
}
catch (Exception ex)
{
string gg = ex.Message;
throw;
}
}
else
{
if (!isError)
{
fileItem.MoveTo(fileItem.FullName + ".type_error");
}
if (!caseOK)
{
fileItem.MoveTo(fileItem.FullName + ".caseno_error");
}
if (!nameOK)
{
fileItem.MoveTo(fileItem.FullName + ".navngivning_error");
}
}
i++;
}
}
}
}
modified 5-Oct-12 4:08am.
|
|
|
|
|