Yes , thanks , I use If and else when dbIsNull . It works .
nassimnastaran
Posts
-
DaraReader problem ... -
DaraReader problem ...I want To do This :
BuyAmount.Text = "0";
When there is No Row in dataReader thanks
-
DaraReader problem ...Hi ALL ! I want to execute this by OledbDataReader when I want to take ... :
string CalcQuery = @"SELECT SUM(BuyAmount) From SubTblMetal WHERE IDMetal=" + int.Parse(txtId.ToString());
OleDbCommand cmdCacl;
cnnCalc.Open();
cmdCacl = new OleDbCommand(CalcQuery, cnnCalc);
OleDbDataReader dr;
dr = cmdCacl.ExecuteReader();
if (dr.HasRows==false)
{
txtBuyAmount.Text = "0";
throw new Exception();
}
else if (dr.Read())
{
txtBuyAmount.Text = dr[0].ToString();}
But when my DataReader has not any row ,I have an error for the value of txtBuAmount.Text please Help , how can get the value of Zero (0) , when dataRow has not any row(value). Thanks a lot !
-
Save in related table ...Yes , but I want that the User have an option to Fill datagrid(subTable) or not , so it can be Blank ... thanks
-
Save in related table ...Hi there ! I have two table (mainTable & SubTable) with these fileds : mainTable --> IdMetal , NameMetal , Formula , ... SubTable --> IDDetails,IdMetal , Company , ... also mainTable.IdMetal=SubTable.IdMetal in myForm , I have some TextBox that filled by MainTable Fields and Datagrid that filled by subTable Fields when I want to create New row(Save) in main table , at the same time i want to fill and save in datagrid , here is my code :
try
{
// for MainTable ...
OleDbConnection cnnSave=new OleDbConnection(myConnection);
OleDbCommand cmd__AddRows = new OleDbCommand();
cmd__AddRows.CommandText =
@"INSERT INTO MainRegTable (IDMetal,NameMetal,FormulMetal, GroupMetal, CodeMetal,Comments)
VALUES (@p1,@p2,@p3,@p4,@p5,@p6)";
cmd__AddRows.Parameters.Clear();
cmd__AddRows.Parameters.AddWithValue("@p1", txtID.Text);
....
//for subTable ...
OleDbDataAdapter dagrd = new OleDbDataAdapter(@"Select * From SubTblMetal
WHERE IDMetal=
"+int.Parse(txtID.Text),
cnnSave);
DataSet dsGrd = new DataSet();
dagrd.Fill(dsGrd, "SubTblMetal");
dsGrd.GetChanges();
dagrd.Update(dsGrd);
dsGrd.AcceptChanges();but , no changes in subtable ... thanks for Reply
power is knowledge ...
-
How to refresh or update DataGrid Cell Value ...thanks , it solve the problem ! ;)
-
How to refresh or update DataGrid Cell Value ...Hi all ! I want to save the DataGrid Cell Value into an excel file :
...
try
{
mySheetInputData = (Microsoft.Office.Interop.Excel.Worksheet)ExWorkBookInputData.Sheets["Sheet1"];mySheetInputData = (Microsoft.Office.Interop.Excel.Worksheet)ExWorkBookInputData.ActiveSheet;
mySheetInputData.Name = "mySheet";
...
for (int i = 0; i < RowCount; i++)
{
for (int j = 0; j < ColumnCount; j++)
{
mySheet.Cells[i + 2, j + 2] = dgv.Rows[i].Cells[j].Value;
if (dgv.Rows[i].Cells[j].Value == null || dgvRows[i].Cells[j].Value.Equals(""))
mySheet.Cells[i + 2, j + 2] = 0.0;
}
}dgv.update();
....
when I save this to an excel file , last cell i fill , show the value of "0.0" , but when I resize or minimize the application or change the cursor in the next cell that fill before , there is no problem to show all value i put to DataGrid Cell. thanks a lot !
-
How to open File using System.Diagnostics.Start in the Base Root directorythanx ! ;)
-
How to open File using System.Diagnostics.Start in the Base Root directory@"..\Debug\HelpFile.pdf"); It's works ! Thanks in advance! Regards !
-
How to open File using System.Diagnostics.Start in the Base Root directoryHi All ! I have a pdf file, place in the debug directory (in any drive) . I want to open this file with any full path :
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
Process.Start(appPath + "\\Debug\\HelpFile.pdf");But I have an error that can not file file , pl z help me ! thanks in advance !
-
Error in loading excel file in windows 7 ...64 bit
-
Error in loading excel file in windows 7 ...System.InvalidOpertionException:The 'Microsoft.ACE.OLEDB.12.0' provider
-
Error in loading excel file in windows 7 ...Hi all ! in my project to reading an excel file , there is no problem in windows XP , but in Win Seven(7) , I have problem to reading the excel 2007 file . here in some part of code :
string connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0;HDR=YES;IMEX=1;""", openFileDlgData.FileName);
string SheetName = "Test";
string query = String.Format(@"select * from [{0}$]", SheetName);
try
{
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, conn);
System.Data.DataTable dt = new System.Data.DataTable("ExcelData");
dataAdapter.Fill(dt);
...Thanks in any help !
-
Export Mutiple DataGridView to Multiple Sheets in an Excel File ...Hi all ! I want o export 2 datagridview in 2 sheets of An Excel File . some code for one DataGridView is Here :
...
Microsoft.Office.Interop.Excel.Worksheet mySheetInputData = null;
try
{
mySheetInputData = (Microsoft.Office.Interop.Excel.Worksheet)ExWorkBookInputData.Sheets["Sheet1"];mySheetInputData = (Microsoft.Office.Interop.Excel.Worksheet)ExWorkBookInputData.ActiveSheet; mySheetInputData.Name = "First Sheet";
// storing header part in Excel
for (int i = 1; i < dgv.Columns.Count + 1; i++)
{
mySheetInputData.Cells[1, i + 1] = dgv.Columns[i - 1].HeaderText;
}
for (int j = 1; j < dgv.Rows.Count + 1; j++)
{
mySheetInputData.Cells[j + 1, 1] = dgv.Rows[j - 1].HeaderCell.Value.ToString();
}
// storing Each row and column value to excel sheetfor (int i = 0; i < dgv.Rows.Count; i++) { for (int j = 0; j < dgv.Columns.Count; j++) { mySheetInputData.Cells\[i + 2, j + 2\] = dgv.Rows\[i\].Cells\[j\].Value.ToString(); } } //save the application string fileNameInputData = String.Empty; SaveFileDlgInputData.Filter = "Excel Files (\*.xlsx)|\*.xlsx"; SaveFileDlgInputData.FilterIndex = 2; SaveFileDlgInputData.RestoreDirectory = true; if (SaveFileDlgInputData.ShowDialog() == DialogResult.OK) { fileNameInputData = SaveFileDlgInputData.FileName; ExWorkBookInputData.SaveAs(fileNameInputData, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); } else return; ...
thanks for any help
-
importing RowName and ColumnName from an excelfile to a datagridview ...Thanks for your reply , Here is my file , pl z check it . or : www.4shared.com/rar/6WxLLxtL/ReadFromExcelFile.html I've prob yet ! thanks!
-
importing RowName and ColumnName from an excelfile to a datagridview ...Hi All ! I want to Import an Excel File to a DataGridView as FirstRow (Except A1 Cell that's null)will be Column HeaderCell in DataGridView and First Column in Excel file (Except Cell of A1=null) will be Row HeaderCell in DataGridView .Here is my code :
string connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0;HDR=YES;IMEX=1;""", openFileDialog1.FileName);
string query = String.Format("select * from [{0}$]", SheetName);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connectionString);DataSet ds = new DataSet();
dataAdapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];int row = ds.Tables[0].Rows.Count;
int col = ds.Tables[0].Columns.Count;for (int i = 0; i < row - 1; i++)
{
dataGridView1.Rows[i].HeaderCell.Value = ds.Tables[0].Rows[i].ToString(); ;
}for (int j = 0; j < col - 1; j++)
{
dataGridView1.Columns[j].HeaderCell.Value = ds.Tables[0].Columns[j].ToString();
}But I have some Problem for Header Column And Header Row . Thanks For Any Help .
-
how to reduce the size of exe File ...RobCroll wrote:
Obfuscation will not only make the exe smaller but also protect your IP.
Really! I didn't know this before ! :omg:
-
how to reduce the size of exe File ...Hi All ! the size of my exe file is about 1.5 mb .I just used Microsoft.Office.Interop.Excel.dll and Word in preferences. thanks for any help me to introduce a way to decrease the size of Exe file. Regards !
-
How to input in DataGridView cell Only Double ... or ...thanks , It's a good Lesson ! ;)
-
How to input in DataGridView cell Only Double ... or ...Hi All , I want to input in DatagridView Cell , Only Double Like 2.36 or 0.035 . how can I do it ? Thanks in Advance for Any Help !