Click here to Skip to main content
15,907,687 members
Home / Discussions / Database
   

Database

 
Questiontow stored procedure Pin
yazan_zahi4-Sep-06 23:00
yazan_zahi4-Sep-06 23:00 
AnswerRe: tow stored procedure Pin
_AK_4-Sep-06 23:19
_AK_4-Sep-06 23:19 
GeneralRe: tow stored procedure Pin
yazan_zahi4-Sep-06 23:26
yazan_zahi4-Sep-06 23:26 
GeneralRe: tow stored procedure Pin
_AK_5-Sep-06 3:16
_AK_5-Sep-06 3:16 
QuestionSet field to "Allow Zero Length" Pin
myNameIsRon4-Sep-06 22:36
myNameIsRon4-Sep-06 22:36 
QuestionWrite XML File Using SQL Server 2000 Pin
FriendlySoluations4-Sep-06 21:41
FriendlySoluations4-Sep-06 21:41 
AnswerRe: Write XML File Using SQL Server 2000 Pin
Marek Grzenkowicz4-Sep-06 22:55
Marek Grzenkowicz4-Sep-06 22:55 
QuestionSystem.ArgumentException in accesing data from DatagridView Pin
Rocky#4-Sep-06 20:49
Rocky#4-Sep-06 20:49 
hello every one!

well I got this query here, I'm really stuck in this error. I'm working oin a master detail form in .net 2.0 C# in Windows Forms. its a System.ArgumentException that I'm getting here. I've these dataGridview on the form. I've made a typed dataset for it. the tables are these

PurchBill(PurchBillID, VendID, Bookno, BillDate)

Purch(purchID,purchbillID,Serial, ModelID, PresentAt,PurchWarranty,PurchPrice)

ProdLine

ProdModel

and vu_manNames thats a view

I've set up seperate dataGridViews for Purch, ProdLine and ProdModel and for selecting the manufacturer name here. Look at this code





private void saverecord()
{
try
{

int n = 0;
if (flagUpdate == false)
{
for (int row = 0; row < dataGridViewPurch.Rows.Count; row++)
{
DataRow dr = dsPurch1.Purch.NewRow();
dr["PurchBillID"] = sqlInsertCommandPurch.Parameters["@purchBillID"].Value = dsPurch1.PurchBill[this.BindingContext[dsPurch1, "PurchBill"].Position].PurchBillID;

MessageBox.Show("Value of Serial \n" + dataGridViewPurch.Rows[row].Cells["Serial"].Value.ToString());


dr["Serial"] = sqlInsertCommandPurch.Parameters["@Serial"].Value = dataGridViewPurch.Rows[row].Cells["Serial"].Value.ToString();
dr["PurchPrice"] = sqlInsertCommandPurch.Parameters["@PurchPrice"].Value = Convert.ToDecimal(dataGridViewPurch.Rows[row].Cells["PurchPrice"].Value.ToString());
MessageBox.Show("Value of ModelID: " + dsPurch1.ProdModel[this.BindingContext[dsPurch1, "ProdModel"].Position].ModelID.ToString());
dr["PurchWarranty"] = sqlInsertCommandPurch.Parameters["@Purchwarranty"].Value = Convert.ToDecimal(dataGridViewPurch.Rows[row].Cells["PurchWarranty"].Value.ToString());

dr["modelID"] = sqlInsertCommandPurch.Parameters["@ModelID"].Value = dsPurch1.ProdModel[this.BindingContext[dsPurch1,"ProdModel"].Position].ModelID ;

dsPurch1.Purch.Rows.Add(dr);
//MessageBox.Show("Hello");
n += daPurch.Update(dsPurch1, dsPurch1.Purch.ToString());

//refreshDataSet();

}
MessageBox.Show("Number of records inserted: " + n.ToString());
dsPurch1.AcceptChanges();

}
else
{
//this code is for the updating a record.

for (int row = 0; row < dataGridViewPurch.Rows.Count; row++)
{

if (dataGridViewPurch.Rows[row].Cells["PurchPrice"].Value.ToString().Length != 0)
{
dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].BeginEdit();
sqlUpdateCommandPurch.Parameters["@PurchBillID"].Value = dsPurch1.PurchBill[this.BindingContext[dsPurch1, "PurchBill"].Position].PurchBillID = Convert.ToDecimal(dataGridViewPurch.Rows[row].Cells["PurchBillID"].Value.ToString());

//sqlUpdateCommandPurch.Parameters["@PurchBillID"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchBillID = Convert.ToDecimal(dataGridViewPurch.Rows[row].Cells["PurchBillID"].Value.ToString());
sqlUpdateCommandPurch.Parameters["@PresentAt"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PresentAt = 1;
sqlUpdateCommandPurch.Parameters["@ModelID"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].ModelID = Convert.ToDecimal(dataGridViewProdModel.SelectedRows[0].Cells["ModelID"].Value.ToString());

for (int col = 0; col < 3; col++)
{
if (col == 0)
sqlUpdateCommandPurch.Parameters["@PurchPrice"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchPrice = Convert.ToDecimal(dataGridViewPurch.Rows[row].Cells["PurchPrice"].Value.ToString());
else if (col == 1)
sqlUpdateCommandPurch.Parameters["@Serial"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].Serial = dataGridViewPurch.Rows[row].Cells["serial"].Value.ToString();
else
sqlUpdateCommandPurch.Parameters["@Purchwarranty"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchWarranty = Convert.ToDecimal(dataGridViewPurch.Rows[row].Cells["PurchWarranty"].Value.ToString());

sqlUpdateCommandPurch.Parameters["@Original_PurchID"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchID;
sqlUpdateCommandPurch.Parameters["@Original_purchBillID"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchBillID;
sqlUpdateCommandPurch.Parameters["@Original_purchPrice"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchPrice;
sqlUpdateCommandPurch.Parameters["@Original_Serial"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].Serial;
sqlUpdateCommandPurch.Parameters["@Original_PurchWarranty"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PurchWarranty;
sqlUpdateCommandPurch.Parameters["@Original_PresentAt"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].PresentAt;
sqlUpdateCommandPurch.Parameters["@Original_ModelID"].Value = dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].ModelID;


MessageBox.Show("Position\n" + this.BindingContext[dsPurch1, "Purch"].Position.ToString());

dsPurch1.Purch[this.BindingContext[dsPurch1, "Purch"].Position].EndEdit();
n += daPurch.Update(dsPurch1, "Purch");
dsPurch1.AcceptChanges();

MessageBox.Show("Number of records updated" + n.ToString());


}
}
else
{
MessageBox.Show("Invalid Serial no");
}


}

}

//btnNavFirst.Enabled = btnNavNext.Enabled = btnNavPrev.Enabled = btnLast.Enabled = true;
}
catch (DBConcurrencyException ex)
{
MessageBox.Show("Zero records affected.\n\n" + ex.ToString());
}
catch (SystemException ex)
{
MessageBox.Show("The source table could not be found.\n\n" + ex.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

=======================================================================
this is meant to save and update as necessary and I’m getting the error on the line I’ve made bold and it says that

System.ArgumentException: Column names Serial can not be found
Parameter name: columnName
At system.Windows.Forms.DataGridViewCellCollection.get_Item(String columnName)

I’ve set up the datamember property to u know the child of PurchBill that is the purch table. I think there are a few errors in the datagridView class (maybe).

Plz help me out of this, I think I’m getting crazy here
Thanks in advance







What I don’t understand is that I’ve done the same work for anoter form in the same fashion and its working fine. It seems to me that there is no property named with these columns here but why is this happenin? And what should I do abt it?


Rocky
QuestionThe text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. Pin
uwhockey4-Sep-06 10:10
uwhockey4-Sep-06 10:10 
AnswerRe: The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. Pin
Marek Grzenkowicz4-Sep-06 23:02
Marek Grzenkowicz4-Sep-06 23:02 
GeneralRe: The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. Pin
uwhockey5-Sep-06 5:20
uwhockey5-Sep-06 5:20 
GeneralRe: The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. Pin
Member 965-Sep-06 6:51
Member 965-Sep-06 6:51 
QuestionMigrating SQL server 2000 database to SQL server 2005 with Japanese alphabets Pin
VaibhavJ4-Sep-06 4:38
VaibhavJ4-Sep-06 4:38 
Questionlayout query Pin
srinandan..4-Sep-06 2:06
srinandan..4-Sep-06 2:06 
AnswerRe: layout query Pin
SeMartens4-Sep-06 2:32
SeMartens4-Sep-06 2:32 
GeneralRe: layout query Pin
srinandan..4-Sep-06 2:40
srinandan..4-Sep-06 2:40 
QuestionWhich one's the best----Relational or non-relational DB structure? Pin
kamalika_kk4-Sep-06 0:07
kamalika_kk4-Sep-06 0:07 
AnswerRe: Which one's the best----Relational or non-relational DB structure? Pin
Colin Angus Mackay4-Sep-06 0:51
Colin Angus Mackay4-Sep-06 0:51 
GeneralRe: Which one's the best----Relational or non-relational DB structure? Pin
Paul Conrad4-Sep-06 7:18
professionalPaul Conrad4-Sep-06 7:18 
Questionsql 2000 installing problem Pin
yazan_zahi3-Sep-06 22:27
yazan_zahi3-Sep-06 22:27 
AnswerRe: sql 2000 installing problem Pin
yahao9-Oct-06 23:58
yahao9-Oct-06 23:58 
Questionmod div Pin
TAREQ F ABUZUHRI3-Sep-06 22:02
TAREQ F ABUZUHRI3-Sep-06 22:02 
AnswerRe: mod div Pin
Eric Dahlvang5-Sep-06 3:23
Eric Dahlvang5-Sep-06 3:23 
QuestionUpgrading an SQL Database via one click Pin
Martin J Evans3-Sep-06 22:02
Martin J Evans3-Sep-06 22:02 
AnswerRe: Upgrading an SQL Database via one click Pin
Eric Dahlvang5-Sep-06 3:20
Eric Dahlvang5-Sep-06 3:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.