473,396 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem in inserting from datagrid

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....
Regards
Ramakrishna

Apr 19 '06 #1
2 1506
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
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
SqlParameter("@i1",SqlDbType.Char,21,"trans_id");
i1.SourceVersion = DataRowVersion.Current;
_DataAdapterTitles.InsertCommand.Parameters.Add(i1 );

SqlParameter i2 = new
SqlParameter("@i2",SqlDbType.Char,5,"ac_code");
i2.SourceVersion = DataRowVersion.Current;
_DataAdapterTitles.InsertCommand.Parameters.Add(i2 );

SqlParameter i3 = new
SqlParameter("@i3",SqlDbType.Char,4,"trans_type");
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;
i8.Value=clsGeneral.uid;
_DataAdapterTitles.InsertCommand.Parameters.Add(i8 );

SqlParameter i9 = new
SqlParameter("@i9",SqlDbType.DateTime,8,"trans_dat e");
i9.SourceVersion = DataRowVersion.Current ;
i9.Value=DateTime.Now.ToString("MM/dd/yyyy");
_DataAdapterTitles.InsertCommand.Parameters.Add(i9 );

Apr 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Bruce Stockwell | last post by:
the setup: Webservice/WinClient application/SQL server. VS.Net (visual basic) winform wizard creates a simple form with load cancel cancelall and datagrid bound to a simple Dataset with one...
5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
2
by: a | last post by:
NEW Post Here's my best guess at how to insert this dataset.... the code runs, but no new records are added to the sql table. I've read and split a delimited text file into a dataset. It...
1
by: Muhammad Usman | last post by:
Respected Assistant I have table in a database named "student" having fields like name of student,Roll No and Status.The status is one of them absent,present or leave.The name and rollno field...
6
by: yoshitha | last post by:
hi db : sql server 2000 lan : C#.net(ASp.Net) in my database table there are 2 fileds of data type datatime. in field 1 i'm storing date in field 2 i'm storing time.
1
by: Krishna | last post by:
Hi, all I have developed one form which will allow user to enter data through datagrid, that datagrid is bound with comboboxes, textboxes. in thise two textboxes are readonly property is true....
0
by: Erik | last post by:
Why isn't my update method getting called? Pasted below is an aspx from a 1.1 application I'm working on. It has two textboxes and a button for inserting data into the database, and a datagrid...
3
by: rcoco | last post by:
Hi, I want to share this problem. I have a datagrid that will help me Insert data into sql database. So I made a button On my form so that when I press the button a new row on datagrid should be...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.