Save data from unbound datagridview to database table.
Hi, i have a unbound datagridview that contain 8 columns i added data in it using the following code:
Dim i As Integer = DataGridViewX1.Rows.Count - 1
Me.DataGridViewX1.Rows.Add()
With Me.DataGridViewX1.Rows(i)
.Cells("id").Value = Format(i, "0000")
.Cells("design").Value = TextBoxX1.Text
.Cells("than").Value = TextBoxX2.Text
.Cells("lace").Value = TextBoxX3.Text
.Cells("color").Value = ComboBoxEx1.Text
.Cells("barcode").Value = ComboBoxEx1.Text
.Cells("received").Value = TextBoxX4.Text
.Cells("description").Value = TextBoxX5.Text
End With
when i click on the add button the data is added to the datagridview. Now what i want is to save this data that i added in unbounded datagridview to my database table.
Plz Help Me...
Thank You.
From DataGridView to a MS Access?
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Windows.Forms
Public Class Form1
Inherits System.Windows.Forms.Form
Private bindingSource1 As New BindingSource()
Private dataAdapter As New OleDbDataAdapter()
<STAThreadAttribute()> _
Public Shared Sub Main()
Application.Run(New Form1())
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Ryan\Desktop\Coding\Microsoft Access\Northwind_2012.mdb"
Dim selectCommand As String
Dim connection As New OleDbConnection(connectionString)
selectCommand = "Select * From MyExcelTable ORDER BY ID"
Me.dataAdapter = New OleDbDataAdapter(selectCommand, connection)
With DataGridView1
.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader
End With
Dim commandBuilder As New OleDbCommandBuilder(Me.dataAdapter)
Dim table As New DataTable()
table.Locale = System.Globalization.CultureInfo.InvariantCulture
Me.dataAdapter.Fill(table)
Me.bindingSource1.DataSource = table
Dim data As New DataSet()
data.Locale = System.Globalization.CultureInfo.InvariantCulture
DataGridView1.DataSource = Me.bindingSource1
Me.DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Aqua
Me.DataGridView1.AutoResizeColumns( _
DataGridViewAutoSizeColumnsMode.AllCells)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, btnUpdate.Click
Dim table As New DataTable()
Me.bindingSource1 = Me.DataGridView1.DataSource
table = Me.bindingSource1.DataSource
Me.dataAdapter.Update(table)
End Sub
End Class
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.
Similar Messages
-
Import/insert data from XML into Oracle database tables?
Hi. (I am using JDeveloper 10.1.3.3.0 and Oracle 10g)
I have been able to export the data from one of my database tables by using a View Object and .writeXML.
Now, I want to take an xml file that is formatted in the same way as what is spit out by the writeXML and put that info in my database table. I followed online examples and have tried using .readXML like so:
Element element = XMLDoc.getDocumentElement();
vo.readXML(element, -1);
I know it is sort of working, because at first I got an error message that one of the required attributes was missing. So, I added that attribute to my xml file and ran my code. No errors. But, I checked my database, and the new records were not added.
Is there something I have done wrong? Or is there perhaps something I left out? I also noticed there were several versions of readXML like readFromXML. Which one should I use and how?
Thanks.KUBA, I changed my code to match your example:
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
File xmlFile = new File("C:/myfilehere.xml");
Document doc = db.parse(xmlFile);
Element element = doc.getDocumentElement();
vo.readXML(element, -1);
vo.getDBTransaction().commit();
I still get no errors, but my database table has no new records.
Any ideas why?
Thanks. -
How to extract data from text file to database table
Hi ,
I am trying to upload data in text file to database table using GUI_UPLOAD function .what would be the program for that.
thanks in advance.Hi,
I don't think you have a standard sap program to upload data from file to database table...
Instead you can create a custom program like this..
DATA: T_FILEDATA(1000) OCCURS 0 WITH HEADER LINE.
DATA: T_ZTABLE LIKE ZTABLE OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\TEST.TXT'
tables
data_tab = T_FILEDATA
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT T_FILEDATA.
T_ZTABLE = T_FILEDATA.
APPEND T_ZTABLE.
ENDLOOP.
MODIFY ZTABLE FROM TABLE T_ZTABLE.
COMMIT WORK..
Thanks,
Naren -
Moving data from .xls spreadsheet to database table
Hi,
Does any one know a script or the procedure to move data from an .xls spreadsheet to a database table?
Thanks,
RanjanaHi,
check this out.. !!
Import data from Excel to Oracle Database and
Added link From Ask Tom.. your requirement you would be satisfied.. I supppose.. !!
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:908428873069
- Pavan Kumar N -
Uploading Datas From Spread sheet to Database Table
I went to URL http://htmldb.oracle.com/pls/otn/f?p=38131:1 and download Vikas' CSV Upload application (a zip file) as well as the script to create the HTMLDB_TOOLS package.
I follow the steps in the link : Re: File Browse, File Upload
The application is created,Preview shows that the datas in the form of Excel sheet,but I cant upload the spread sheet.
If I click the Upload button It shows the Error:
ORA-01861: literal does not match format string
Error ORA-01861: literal does not match format string
OK
Kindly let me know the reason for the error.
Please help me to solve this Issue.
Thanks in Advance
by
SureshHi Gussay,
Thanks for ur reply.
I found the error,it was due to the date format.
If i drop the date column from the table and also from spread sheet,then it uploads.
How can we load dates in spread sheet to database column.
Thanks in advance
Suresh -
Query for inserting data from OAF page to database table
I need to insert a row into a table by getting parameters from pageContext. The fields in this page are from multiple view objects and the data in these fields should be inserted into a table. If anyone can provide solution in this regard will be very much helpful.
Hi Rma,
My Understanding is...
Say you want to display information of 10 customers. Hence there will be 10 rows to display.
Say number 5 customer has maximum accounts 15 (In case there is variable number of accounts for each customer). Hence there will be max 15 columns.If the above under standing is correct, then a question...is there an upper limit on number of accounts for a customer?
If yes then I may say...
Create a custom table with that many columns as of max number of alloweed accounts.
Write a plsql api to insert column of existing table as row in the custom table.
Now base your EOs and VOs on that custom table. That may show columns in term of rows on your screen.
The logic is, instead of converting column data to row in oaf, do it in plsql.
Now again if it has to be updated by user, create a reverse api to put data from custom table to existing table.
However, this approach can lack automatic features on existing seeded table(like validations), provided by EO. Hence you must explore PL/SQL Entity objects in Dev guide before going with this approach (both are near same but you may be able to better judge which one will be more suitable for your need.
Another insant approach which strike in mind is just modifying logic in controller to modify bean hierarchy (adding columns at run time) or by create VO dynamically.
However, possibly that can put other complexities of personalization and maintainance of code etc.
Hence the suggestion is...Evaluate all three and judge which one is most suitable for you over all needs (First try with PL/SQL Base EOs Or with the above approach or pure java manipulation)
Seems too complex approaches all. Other users must pour there thoughts.
Abdul Wahid -
How to save data from form into database
i nid to save data from form into the new table, @abc.
got any idea ?
smtg like oObj = BaseAddOn.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes) this but it is a new object or user data source.
Thankshi
i have created UDO i have also done registration i want to bind item master completely to matrix and then in one column i will set check box to check unchecked and then i want to save it to database
i have one user defined form and 4 matrix and 4 child tables
for each matrix i have given 1 form and i have to transfer the data from temp form to main form matrix having large data in matrix on temp form to main form matrix
to load data on matrix i have used for loop that i want to avoid so how i can bind large data to matrix without for loop
regards
amey -
Passing data from JAVASCRIPT to SAP database
Hi Experts,
Is it possible to connect or access RFC function module through JAVASCRIPT? I want to send data from JAVASCRIPT to SAP database table.
Is it possible to pass data from JAVASCRIPT to SAP database table?
Thanks in advance.
Regards,
Arindam Samanta.OData services can be one option to achieve this.
Another possibility can be use of Generic REST enablement with SAP NetWeaver Gateway.
If you are not considering Gateway at all, then A JSON adapter like the one mentioned in JSON Adapter for ABAP Function Modules can be handy. -
Save Data From Grid to Database
Hello All,
I want to create a form to save data from a grid to the database just like the SAP Forecast Form .
My requirements are as follows :-
I have created a Table in which there are three fields ItemCode,Date,Qty
But while entering user will first select the Date ranges (from - To) and based on that date range
no. of columns will be created as it will be dynamic and then user will enter the corresponding quantity for that item and date
just like the Sales Forecast (SAP) Form .
Form will be like :-
From Date - 10/10/11 ToDate - 13/10/11
Row Levels Fields :-
ItemCode 10/10/11 11/10/11 12/10/11 13/10/11
A0001 100 150 200 300
While updating system will put the data in database table as :-
ItemCode Date Quantity
A0001 10/10/11 100
A0001 11/10/11 150
A0001 12/10/11 200
A0001 13/10/11 300
This is what i want to do .
Please suggest how to proceed with this using a Matrix or a grid.
Thanks & Regards,
Amit
Edited by: AmitSharma_061985 on Oct 19, 2011 7:08 AMHi,
If you are doing it with oops concept then here are the steps for that.
1) Declare DATA : er_data_changed TYPE REF TO cl_alv_changed_data_protocol,
data_changed TYPE REF TO cl_alv_changed_data_protocol.
--For getting the row no of of the row which is edited by user
DATA : ls_mod_cell TYPE table of lvc_s_modi with header line,
lv_value TYPE lvc_value .
in your program
2) Define a class
CLASS notification DEFINITION.
PUBLIC SECTION.
CLASS-METHODS : handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING er_data_changed.
ENDCLASS. "NOTIFICATION DEFINITION
3) For that class write the implementation
CLASS notification IMPLEMENTATION.
METHOD handle_data_changed.
PERFORM handle_data_changed USING er_data_changed.
ENDMETHOD. "handle_data_changed
ENDCLASS. "NOTIFICATION IMPLEMENTATION
4) In the PERFORM handle_data_changed you code like this
FORM handle_data_changed USING er_data_changed type ref TO
cl_alv_changed_data_protocol.
SORT er_data_changed->mt_mod_cells BY row_id .
LOOP AT er_data_changed->mt_mod_cells
INTO ls_mod_cell .
append ls_mod_cell.
ENDLOOP.
*LS_MOD_CELL will have all the rows which were edited
and all the updated data corresponding to those rows*
You can now use the the data which is in LS_MOD_CELL
to update into your DB Table.
LOOP at ls_mod_cell.
READ TABLE itab3 INTO t_output INDEX ls_mod_cell-row_id.
ENDLOOP.
ENDFORM. " handle_data_changed
Regards,
Syed -
Is it possible to save / extract data from a MS SQL database 2008 using lookout 6.2?
Now a days we are saving / extracting data in a excel spreadsheet, but we would like to do that using a database because it is better.You can use ODBC connection to work with SQL Server database.
Use SQLExec object to execute the SQL statement. Here is a KB about the SQL statement.
http://digital.ni.com/public.nsf/allkb/4ADEEA04CD24AE0B862565E20002A16F?OpenDocument
To write data to spreadsheet is more straightforward because Lookout has built-in spreadsheet object. But you need to write SQL statement by yourself to interact with other database.
To read the data back is the same way. Just use "select" SQL statement to query. You can use Datatable object to query.
The "Data Source" can be "DSN = data source name;". The data source name is configured in Control Panel->Administrative Tools->Data Sources(ODBC).
Ryan Shi
National Instruments -
*Urgent*How to insert data from MS SQL to the table that create at the adobe form?
Hi,
I'm using Adobe life cycle designer 8 to do my interactive form. I would like to ask how to insert data from MS SQL to the table that i have created in my adobe interactive form?
I really need the information ASAP as i need to hand in my project by next week... i really appreciate any one who reply this post.
ThanksTou need to do a couple of things
1. On the Essbase server, set up an odbc system connection to your MySQL database
2. In the load rule , go to the file menu and select open SQL data source and in the data source put in your SQL statement . A couple of hints. Where it says Select, don't put in the word select and where it say from don't put in from. The system adds them for you. The easiest way ti enter a SQL statement is to do it all in the select area So if your SQL would normanlly say select * from mytable just enter the code as * from mytable in the select area
The click ol/retrieve and enter in your connection info. Itshould bring data back into the load rule. Save the load rule and use it -
Inserting data from jsp form to multiple tables !
Hi,
I want to insert data from jsp form to two tables
tables are
(1) Form
formId (PK)
deptName
(2) Data
formId (FK)
sNo
description
itemCode
and the problem is that i want to save information form a jsp form to above two tables and i have only one form.
so how do i insert data from a jsp form to multiple tables.You already know what your form in the jsp will be and what fields they are. You also already know what your database looks like. Using one form, you should be able to break the data down, and give it certain ids and/or names, so that when the form is submitted, you retrieve the correct values corresponding to a specific field and insert it.
Unless there is something else I am not catching, this seems pretty straight forward. -
Is it possible to store dat from word file into a table
Hi Experts,
I have an Office UI element on my web dynpro View. It is selected as MS Word. Now I want to save data from this word file to a table in SAP. Can we have a data element which can store such type of large data. Please suggest.
Regards,
Vaibhav Tiwari.>But we can't have a table attribute of this type
Actually you can. You can define a database column as RAW STRING. This is exactly the same as a XSTRING variable and in your SQL statement you just pass it an XSTRING. It will store the entire contents of the XSTRING as a single column in the database. Large size is not a problem. -
Upload data from excel file to Oracle table
Dear All,
I have to upload data from excel file to Oracle table without using third party tools and without converting into CSV file.
Could you tell me please how can i do this using PLSQl or SQL Loader.
Thnaks in Advance..Dear All,
I have to upload data from excel file to
Oracle table without using third party tools and
without converting into CSV file.
Could you tell me please how can i do this
using PLSQl or SQL Loader.
Thnaks in Advance..As billy mentioned using ODBC interface ,the same HS service which is a layer over using traditional ODBC to access non oracle database.Here is link you can hit and trial and come out here if you have any problem.
http://www.oracle-base.com/articles/9i/HSGenericConnectivity9i.php[pre]
Khurram -
Hi Everyone,
I am new to Oracle forms. I have a requirement where user wants a form which can be used to browse a excel file from his/her system. Also after browsing the file the user should be able to load the data from the file to a table in the Oracle DB.
Any help pointers would be appreciated.
Thanks,
Satya
Message was edited by: user12098633Hi Marcus,
I am using EBS (E- Business Suite) ERP and version is 11.5.10.2
My database version is as below
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE
11.2.0.3.0
Production
TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
I want to move csv file via EBS only. Average size of this will be max 600-700 bytes.
Program should be in pl/sql package or concurrent program or custom .fmb (d2k forms) or custom .rdf (d2k report) or through alert. I am not using samba.
Maybe you are looking for
-
Smart Group not working when assigning Card "is not member of"
I'm trying to create a smart group in Address Book, that seems to be failing. What I'd like is a Smart Group where Cards NOT assigned to a certain other group are included in the Smart Group. However, the Smart Group isn't so smart ... in fact, it's
-
Internal Harddrive Maximum Capacity
Does anyone know if I am able to upgrade to an internal Hitachi Travelstar 160 gb ATA harddrive in my iBook G4 (12", 1.2 ghz, OS 10.4.10, 768 GB RAM)? I have heard with ATA 100 there is a cap at 120 gb? Can anyone verify the maximum capacity the iBoo
-
Valu Set Tables /BIC/OB*
Hi, I am experiencing a strange problem with Value Sets. For some reason randomly a Value Set table getting deleted. The definition in Reporting Agent is there and the entry in RSRVTABLEDIR is there but the physical table /BIC/OB* getting deleted. Do
-
Ich habe bisher ca.6000 Bilder in PSA3 und wollte sie in PSE 8 konvertieren. leider kommt immer eine Fehelrmeldung man soll den alten Katalog reparieren und dann einen neuen Versuch starten. Im Album funktioniert alles einwandfrei
-
My Iphone started shutting down and switching back on by itself. After researching problem, lots of results pointed towards restoring phone. I commenced the process and all was going well until the phone shut down during the restore and Itunes then