Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
ඕනම රටකට සෙට් වෙන CV එකක්
ErMurazor
Updated:
Saturday at 9:50 AM
Hambantota
7 Acres Beachfront Land For Sell DownSouth , PerPerch Price 420 000
1024 Digital
Updated:
Wednesday at 11:57 AM
Baseus PI LITE INDOOR CAMERA
ErMurazor
Updated:
Oct 12, 2026
Ad icon
Colombo
Hard Disk For Sale
mazza
Updated:
Oct 10, 2026
land for sale
justasking
Updated:
Oct 10, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
C# - Grid-view to SQL
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="king_pandukabaya" data-source="post: 13894411" data-attributes="member: 279674"><p><span style="font-size: 15px"><strong>දැන් නම් C# මොන ලබ්බක්වත් මතක නෑ මචන්. මීට අවුරුද්දකට කලින් මේක ඇහුවානම් මට හෙල්ප් එකක් දෙන්න තිබ්බා.</strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p><span style="font-size: 15px"><strong>මට මේක කියනවද මචන්, දැන් උඹ ඔය save කරන්නේ datagrid එකේ තියෙන values නම්. ඒ datagrid ඒකට values එන්නේ කොහොමද ?. </strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p><span style="font-size: 15px"><strong>මට තේරෙන හැටියටනම් උඹ කරලා තියෙන්නේ ORD_Class කියලා class එකක් අරගෙන ඒකේ set/get methods දාලා save method එකේදී ඒ ORD_Class එකෙන් instance එකක් හදලා ඒකට ඔය values ටික දාන එක නේද ? මේක නම් මට හිතෙන විදිහට හරියන්නේ නෑ. මොකද මචන් එකේ ගනනාවක් තියෙනවා නමුත් එකේ එක වෙලාවට හදන්නේ එක එකක් විතරයි. </strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p><span style="font-size: 15px"><strong>මේකට විසඳුම මට හිතෙන හැටියට මචන්, save method එකේදී datagrid හැම record එකක්ම datatable එකකට අරගෙන ඒ table එක pass කරන්න ORD_Class එකට</strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p> <span style="font-size: 15px"><strong><span style="color: red">public Boolean AddOrder(Datatable dt) { .... }</span></strong></span></p><p><span style="font-size: 15px"><strong>set get methods ඕනම නෑ ORD_Class එකට එතකොට </strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p><span style="font-size: 15px"><strong><span style="color: red">for(int count=0;count<dt.Rows.Count;count++)</span></strong></span></p><p><span style="font-size: 15px"><strong><span style="color: red"></span></strong></span></p><p><span style="font-size: 15px"><strong><span style="color: red">{</span></strong></span></p><p><span style="font-size: 15px"><strong><span style="color: red"></span></strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p><span style="font-size: 15px"><strong> public Boolean AddOrder(ORD_Class ordObj)</strong></span></p><p><span style="font-size: 15px"><strong> {</strong></span></p><p><span style="font-size: 15px"><strong> SqlConnection conn = new SqlConnection(connection);</strong></span></p><p><span style="font-size: 15px"><strong> string sql = "INSERT INTO ORD_DATA (ORD_NO, ORD_ID, ORD_Date, CUS_Name, CUS_Address, CUS_Contact, PRO_Code, PRO_Name, PRO_Des, PRO_Price, PRO_Qty, ORD_LTotal) values (@ORD_NO1, @ORD_ID2, @ORD_Date3, @CUS_Name4, @CUS_Address5, @CUS_Contact6, @PRO_Code7, @PRO_Name8, @PRO_Des9, @PRO_Price10, @PRO_Qty11, @ORD_LTotal12)";</strong></span></p><p><span style="font-size: 15px"><strong> conn.Open();</strong></span></p><p><span style="font-size: 15px"><strong> SqlCommand cmd = new SqlCommand(sql, conn);</strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p><span style="font-size: 15px"><strong> <span style="color: Red">cmd.Parameters.AddWithValue("@ORD_NO1", dt.[count][0].toString());</span></strong></span></p><p><span style="font-size: 15px"><strong><span style="color: Red"></span></strong></span></p><p><span style="font-size: 15px"><strong><span style="color: Red"></span></strong></span></p><p><span style="font-size: 15px"><strong>......</strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p><span style="font-size: 15px"><strong>ටිකක් මේක බලන්න. ඔය මට හිතිච්ච විදිහ. මම මේක test කලේ නෑ</strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p><span style="font-size: 15px"><strong>ඔච්චර දුක් විඳින්න ඕන නැත්තන් වහාම save method එකේම datagrid එක read කරන ගමන්ම database ඒක එකට කරන්න.</strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p><span style="font-size: 15px"><strong>එහෙමත් නැත්තන් stored procedure කියලා දෙයක් තියෙනවා. ඒකත් යොදාගන්න පුලුවන්. හැබැයි ඒකෙදි sql server එකේදිත් code කරන්න වෙනවා. </strong></span></p><p><span style="font-size: 15px"><strong></strong></span></p><p> <span style="font-size: 15px"><strong></strong></span></p></blockquote><p></p>
[QUOTE="king_pandukabaya, post: 13894411, member: 279674"] [SIZE="4"][B]දැන් නම් C# මොන ලබ්බක්වත් මතක නෑ මචන්. මීට අවුරුද්දකට කලින් මේක ඇහුවානම් මට හෙල්ප් එකක් දෙන්න තිබ්බා. මට මේක කියනවද මචන්, දැන් උඹ ඔය save කරන්නේ datagrid එකේ තියෙන values නම්. ඒ datagrid ඒකට values එන්නේ කොහොමද ?. මට තේරෙන හැටියටනම් උඹ කරලා තියෙන්නේ ORD_Class කියලා class එකක් අරගෙන ඒකේ set/get methods දාලා save method එකේදී ඒ ORD_Class එකෙන් instance එකක් හදලා ඒකට ඔය values ටික දාන එක නේද ? මේක නම් මට හිතෙන විදිහට හරියන්නේ නෑ. මොකද මචන් එකේ ගනනාවක් තියෙනවා නමුත් එකේ එක වෙලාවට හදන්නේ එක එකක් විතරයි. මේකට විසඳුම මට හිතෙන හැටියට මචන්, save method එකේදී datagrid හැම record එකක්ම datatable එකකට අරගෙන ඒ table එක pass කරන්න ORD_Class එකට [COLOR="red"]public Boolean AddOrder(Datatable dt) { .... }[/COLOR] set get methods ඕනම නෑ ORD_Class එකට එතකොට [COLOR="red"]for(int count=0;count<dt.Rows.Count;count++) { [/COLOR] public Boolean AddOrder(ORD_Class ordObj) { SqlConnection conn = new SqlConnection(connection); string sql = "INSERT INTO ORD_DATA (ORD_NO, ORD_ID, ORD_Date, CUS_Name, CUS_Address, CUS_Contact, PRO_Code, PRO_Name, PRO_Des, PRO_Price, PRO_Qty, ORD_LTotal) values (@ORD_NO1, @ORD_ID2, @ORD_Date3, @CUS_Name4, @CUS_Address5, @CUS_Contact6, @PRO_Code7, @PRO_Name8, @PRO_Des9, @PRO_Price10, @PRO_Qty11, @ORD_LTotal12)"; conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); [COLOR="Red"]cmd.Parameters.AddWithValue("@ORD_NO1", dt.[count][0].toString()); [/COLOR] ...... ටිකක් මේක බලන්න. ඔය මට හිතිච්ච විදිහ. මම මේක test කලේ නෑ ඔච්චර දුක් විඳින්න ඕන නැත්තන් වහාම save method එකේම datagrid එක read කරන ගමන්ම database ඒක එකට කරන්න. එහෙමත් නැත්තන් stored procedure කියලා දෙයක් තියෙනවා. ඒකත් යොදාගන්න පුලුවන්. හැබැයි ඒකෙදි sql server එකේදිත් code කරන්න වෙනවා. [/B][/SIZE] [/QUOTE]
Insert quotes…
Verification
Dawasata paya keeyak thibeda?
Post reply
Top
Bottom