473,326 Members | 2,680 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,326 software developers and data experts.

save data in Access from datagridview which is filled from different textboxes

i'm developing software for Production Planning i which i find some problems :
1. My datagridview contains data from different text boxes , textboxes are getting data from different tables (eg with help forms in my application ) . Now i want to save this filled grid in database. for which i tried this :

Private Sub btnSave_Click(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles btnSave.Click
Dim NoRows As Integer
With GridProdDet
NoRows = .RowCount
For i = 1 To NoRows - 1
If AddFlg = True Then
Call InsertRecords(.Item(0, i).Value, .Item(1, i).Value, .Item(2, i).Value, .Item(3, i).Value, .Item(4, i).Value, .Item(5, i).Value, .Item(6, i).Value, .Item(7, i).Value, .Item(8, i).Value, .Item(9, i).Value, .Item(13, i).Value, .Item(14, i).Value)
End If
Next
End With
End Sub

Private Sub InsertRecords(ByVal Mach As Integer, ByVal head As String, ByVal Part As String, ByVal desc1 As String, ByVal modelNm As String, ByVal mdCd As Integer, ByVal ShftNo As Integer, ByVal ShftType As String, ByVal TimeFr As Integer, ByVal TimeTo As Integer, ByVal sec As Integer, ByVal scrp As Integer)

Dim str As OleDbConnection
Dim cmdSaveProdTube As OleDbCommand
str = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=E:\TubeProd\production.mdb;")
str.Open()
cmdSaveProdTube = New OleDbCommand
Try
With cmdSaveProdTube
.Connection = str
.CommandText = "Insert into tblinfo (mach_no,main_hd, part_no,desc,m_name,model_cd,shift_no,shift_type,t ime_fr,time_to,sec_qty,scrp_qty)" & _
"Values('" & Mach & "', '" & head & "', '" & Part & "', '" & desc1 & "', '" & modelNm & "','" & mdCd & "','" & ShftNo & "','" & ShftType & "','" & TimeFr & "','" & TimeTo & "', '" & sec & "','" & scrp & "' )"
.ExecuteNonQuery()
End With
MsgBox("Sucessfully Save!", MsgBoxStyle.Information, "")
Catch ex As Exception
MsgBox("Error Saving Records", vbExclamation, "")
End Try

End Sub

This is program is not saving data in database.
Dec 8 '11 #1
0 999

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access...
4
by: Oyvind | last post by:
I'm working on a Windows forms/C# database application. My background is 6-7 years of VB 4 - 6, MS Access, VC++, mixed in with a lot of T-SQL and MS SQL Server in general and some OOA/OOD. ...
3
by: abc my vclass | last post by:
There are some programs written on .NET 1.1. These applications are apply n-tiers contains Data Access Layers or Business Logic Layer. Now, our company upgrade to .NET 2.0 and enhance or rewrite...
6
by: alexia.bee | last post by:
Hi all, I am new to C# so please bear me :). I have an app which uses datagridview. it has 8 columns. I also have struct which has 8 members(the same as the datagridview). when I add row to...
7
by: BillE | last post by:
What is the best way to add data using a DataGridView in a multi-tier application (data entry is handled in a data access layer using stored procedures)? Thanks Bill
2
by: Torilyn73 | last post by:
Alrighty... one problem down... 40 more to go!! (Just kidding.. not really 40.. only 32!) My database needs to be accessible via the web. I have the server information so when its ready I can...
14
by: wassssup | last post by:
hi guys..im new to datagridview and im wondering is there a way to convert an encrypted data in access and show it in a datagridview? im using C# and microsoft access normally this is how to show...
4
by: shripal | last post by:
hello, i am new to c#.net. i have imported data in datagridview form ms access database. now i want to store each row of datagridview saperatly in string array so in saperate class i...
1
by: progvar | last post by:
Hi i want to update data in database using datagridview actually i am displaying the data in datagridview and after that i want to update some rows data directly modifying the displayed data into...
0
by: premMS143 | last post by:
Hi, I have created application using VB.net & backend MS Access. During run time I add certain rows of data to Datagridview. After finalizing it I want to update those data present in datagridview...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.