By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,237 Members | 1,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,237 IT Pros & Developers. It's quick & easy.

Problem in inserting from datagrid

P: n/a
Hi, I have developed a for dataentry by using datagird in C# windows
application, I am using combocolumns, textbox columns for the same,
two readonly textboxcolumns for those readonly columns i will assign
the default value through nulltextproperty. I am getting all these fine
it is inserting,updating without any problem.

But while inserting new rows it is not inserting values related to that
readonly textboxes, can some one help me regarding this, i have struck
in this....

Apr 19 '06 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Whats probably happening is you haven't setup the parameter values in
your sql commands to point to those columns on the grid or that you
haven't set the "value" property you have simply set the text property.
Your SQL command parameters should have a Source column property
makesure that has been set.

Apr 19 '06 #2

P: n/a
Hi, Thanks for the replay.

I specified sourse column and value for the same column, I am using the
following code, please go through the code.

_DataAdapterTitles.InsertCommand = _Conn.CreateCommand();
_DataAdapterTitles.InsertCommand.CommandText =
"INSERT INTO transactions
(trans_id,ac_code,trans_type,payment_type,trans_de scription,dbamount,cramount,uid,trans_date)
" +
"VALUES(@i1, @i2, @i3, @i4, @i5, @i6, @i7,@i8,@i9)";

// Add the parameters for INSERT
SqlParameter i1 = new
i1.SourceVersion = DataRowVersion.Current;
_DataAdapterTitles.InsertCommand.Parameters.Add(i1 );

SqlParameter i2 = new
i2.SourceVersion = DataRowVersion.Current;
_DataAdapterTitles.InsertCommand.Parameters.Add(i2 );

SqlParameter i3 = new
i3.SourceVersion = DataRowVersion.Current;
_DataAdapterTitles.InsertCommand.Parameters.Add(i3 );

SqlParameter i4 = new
SqlParameter("@i4",SqlDbType.Char,4,"payment_type" );
i4.SourceVersion = DataRowVersion.Current;
_DataAdapterTitles.InsertCommand.Parameters.Add(i4 );

SqlParameter i5 = new
SqlParameter("@i5",SqlDbType.Char,200,"trans_descr iption");
i5.SourceVersion = DataRowVersion.Current;
_DataAdapterTitles.InsertCommand.Parameters.Add(i5 );

SqlParameter i6 = new
SqlParameter("@i6",SqlDbType.Decimal,0,"dbamount") ;
i6.SourceVersion = DataRowVersion.Current;
_DataAdapterTitles.InsertCommand.Parameters.Add(i6 );

SqlParameter i7 = new
SqlParameter("@i7",SqlDbType.Decimal,0,"cramount") ;
i7.SourceVersion = DataRowVersion.Current;
_DataAdapterTitles.InsertCommand.Parameters.Add(i7 );

SqlParameter i8 = new SqlParameter("@i8",SqlDbType.Char,10,"uid");
i8.SourceVersion = DataRowVersion.Current;
_DataAdapterTitles.InsertCommand.Parameters.Add(i8 );

SqlParameter i9 = new
SqlParameter("@i9",SqlDbType.DateTime,8,"trans_dat e");
i9.SourceVersion = DataRowVersion.Current ;
_DataAdapterTitles.InsertCommand.Parameters.Add(i9 );

Apr 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.