473,796 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 nulltextpropert y. I am getting all these fine
it is inserting,updat ing 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 1534
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.

_DataAdapterTit les.InsertComma nd = _Conn.CreateCom mand();
_DataAdapterTit les.InsertComma nd.CommandText =
"INSERT INTO transactions
(trans_id,ac_co de,trans_type,p ayment_type,tra ns_description, dbamount,cramou nt,uid,trans_da te)
" +
"VALUES(@i1 , @i2, @i3, @i4, @i5, @i6, @i7,@i8,@i9)";

// Add the parameters for INSERT
SqlParameter i1 = new
SqlParameter("@ i1",SqlDbType.C har,21,"trans_i d");
i1.SourceVersio n = DataRowVersion. Current;
_DataAdapterTit les.InsertComma nd.Parameters.A dd(i1);

SqlParameter i2 = new
SqlParameter("@ i2",SqlDbType.C har,5,"ac_code" );
i2.SourceVersio n = DataRowVersion. Current;
_DataAdapterTit les.InsertComma nd.Parameters.A dd(i2);

SqlParameter i3 = new
SqlParameter("@ i3",SqlDbType.C har,4,"trans_ty pe");
i3.SourceVersio n = DataRowVersion. Current;
_DataAdapterTit les.InsertComma nd.Parameters.A dd(i3);

SqlParameter i4 = new
SqlParameter("@ i4",SqlDbType.C har,4,"payment_ type");
i4.SourceVersio n = DataRowVersion. Current;
_DataAdapterTit les.InsertComma nd.Parameters.A dd(i4);

SqlParameter i5 = new
SqlParameter("@ i5",SqlDbType.C har,200,"trans_ description");
i5.SourceVersio n = DataRowVersion. Current;
_DataAdapterTit les.InsertComma nd.Parameters.A dd(i5);

SqlParameter i6 = new
SqlParameter("@ i6",SqlDbType.D ecimal,0,"dbamo unt");
i6.SourceVersio n = DataRowVersion. Current;
_DataAdapterTit les.InsertComma nd.Parameters.A dd(i6);

SqlParameter i7 = new
SqlParameter("@ i7",SqlDbType.D ecimal,0,"cramo unt");
i7.SourceVersio n = DataRowVersion. Current;
_DataAdapterTit les.InsertComma nd.Parameters.A dd(i7);

SqlParameter i8 = new SqlParameter("@ i8",SqlDbType.C har,10,"uid");
i8.SourceVersio n = DataRowVersion. Current;
i8.Value=clsGen eral.uid;
_DataAdapterTit les.InsertComma nd.Parameters.A dd(i8);

SqlParameter i9 = new
SqlParameter("@ i9",SqlDbType.D ateTime,8,"tran s_date");
i9.SourceVersio n = DataRowVersion. Current ;
i9.Value=DateTi me.Now.ToString ("MM/dd/yyyy");
_DataAdapterTit les.InsertComma nd.Parameters.A dd(i9);

Apr 20 '06 #3

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

Similar topics

8
749
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 Datatable. No coding by programer, All wizardry. User starts app, opens form, adds (4) records and clicks update.
5
2598
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 date, name, address etc) about the selected row in the datagrid... My problem is when I enter a new record in the details tabpage (saves data to database), and go back to the datagrid. Only the data from the PM-table
2
4026
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 looks fine in a datagrid (5 columns and 5,000 rows), but I've been trying, without success, to then insert the resulting dataset called "result" into a single sql table that has an auto-increment and PK column called ID,
1
1274
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 is already entered but the status is entered from datagrid in such a way that name and rollno is feteched from database and display on datagrid and the status is insert from the dropdown list in the datagrid.
6
4441
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
1109
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. Actually the problem is when i update or insert any record it is not updating the data from those readonly columns (remaining columns are inserting/updating), I set the value property for the para,eter. amd at
0
1756
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 for editing and deleting data. When a user clicks on the "Edit" button in the datagrid, Edit() method is called and the appropriate row is changed into textboxes. And if user clicks on the "Update" button, the Update() method is fired. But if...
3
4276
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 created and I could be able to insert data. But with this code below I've failed could someone help me and tell me where I'm going wrong: private void Page_Load(object sender, System.EventArgs e) { if (! IsPostBack)
2
3098
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 section: Discography --------------------- DiscID
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10459
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10237
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10187
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.