Datagrid Saving To A Access Database
Hello
I am using a datagrid and l would like to update and save the contents to the access database. The customer would like to have an excel style grid, that they can navigate and edit details to it, then update. And also they like to be able to add a new record and add that to the database.
I am using the data environment, as l needed to print some reports (working ok)
Code so far.
Code: 'updating deCustomers.rsCmdCustomers.update
'saving deCustomers.rsCmdCustomers.save
Many thanks in advance
Steve
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Datagrid, Saving And Updating To Access Database
Hello
I am using a datagrid and l would like to update and save the contents to the access database. The customer would like to have an excel style grid, that they can navigate and edit details to it, then update. And also they like to be able to add a new record and add that to the database.
I am using the data environment, as l needed to print some reports (working ok)
Code so far.
Code:'updating
deCustomers.rsCmdCustomers.update
'saving
deCustomers.rsCmdCustomers.save
Many thanks in advance
Steve
Saving Datagrid To Access
I am new to VB and having a problem saving my information in the datagrid into an access file or even a text file.
It will save it to excel but it only saves the first record. Can anyone help me with this problem?
Below is the code I have so far for the save feature:
rivate Sub cmdSave_Click()
Dim grdData As String
Dim iFile1 As Integer
iFile1 = FreeFile 'open the file for writing
Open "C:Dataout.csv" For Output As #iFile1
Write #iFile1, " Column1 "
Write #iFile1, " Column2 "
Write #iFile1, " Column3 "
Write #iFile1, " Column4 "
Write #iFile1, " Column5 "
Close #iFile1
End Sub
Saving From Datagrid To Access
Hi all
Anybody know how to save what the user changes in a datagrid (on a form) back in the Access .mdb file? Do i need to use a common dialog box or does the datagrid have a special property/command for that?
Thanx
- stacey xx
Saving To Access Database
I am taking a class and have to make an address book that can store to an access database. I have not been able to find the save code for the save button click event in my book. And for extra credit I need some help with a search button code. Again this information is not in my book.
Thanks,
John
Saving A Access Database
I am trying to setup my first database using access. I have the code written but when I close my project the data that I entered does not save. I have search this website looking for the answer I know it has to be here I jsut cant find it.
Here is my code.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DejarnetteDataSet.Mailing_List' table. You can move, or remove it, as needed.
Me.Mailing_ListTableAdapter.Fill(Me.DejarnetteDataSet.Mailing_List)
End Sub
Private Sub EmployeesBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Validate()
Me.MailingListBindingSource.EndEdit()
Me.Mailing_ListTableAdapter.Update(DejarnetteDataSet.Mailing_List)
End Sub
Private Sub EmployeesBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Validate()
Me.MailingListBindingSource.EndEdit()
Me.Mailing_ListTableAdapter.Update(Me.DejarnetteDataSet.Mailing_List)
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Try
Me.Validate()
Me.MailingListBindingSource.EndEdit()
Me.Mailing_ListTableAdapter.Update(Me.DejarnetteDataSet.Mailing_List)
MsgBox("Update successful")
Catch ex As Exception
MsgBox("Update failed")
End Try
End Sub
Private Sub btnFirstNameSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirstNameSearch.Click
Dim indexNumber As Integer = Me.MailingListBindingSource.Find("FirstName", Me.FindByNameTextBox.Text)
Me.MailingListBindingSource.Position = indexNumber
End Sub
End Class
Thanks in advance for you help.
Two Datagrid Access The Same Database
I have two datagrid which access the same database but with different query command.
When i insert a data into the database the 1st datagrid list all the records just fine.
(i automatically refresh the datagrid so it can list the updated records).
But when i tried to list all the records on the 2nd datagrid, it didn't list the records at all until i close the form and reopen it again, the 2nd datagrid shows the records.
What could be the problem ?
This is my snippet codes :
Code:'This is when i clicked the command button, it will list the records on the 2nd datagrid
'ObjPerkiraan is the object from class CPerkiraan
Private Sub Cmd_Cari_Id_Perkiraan_Induk_Click()
ObjPerkiraan.sql = "Select id_perkiraan,nama_perkiraan from master_perkiraan
where is_Group = -1 order by id_perkiraan"
ObjPerkiraan.dapatkanRsMasterPerkiraan
With DG_Id_Perkiraan_Induk
.Columns(0).Caption = "Id Perkiraan"
.Columns(1).Caption = "Nama Perkiraan"
.HeadFont = "Arial"
.HeadFont.Bold = True
.Visible = Not DG_Id_Perkiraan_Induk.Visible
End With
End Sub
'The method from class CPerkiraan
Public Sub dapatkanRsMasterPerkiraan()
Set rsIdPerkiraanInduk = New ADODB.Recordset
rsIdPerkiraanInduk.CursorLocation = adUseClient
rsIdPerkiraanInduk.Open sqlPerkiraan, con, adOpenKeyset, adLockOptimistic
'rsIdPerkiraanInduk.Resync adAffectAllChapters
Set FrmMasterPerkiraan.DG_Id_Perkiraan_Induk.DataSource = rsIdPerkiraanInduk
FrmMasterPerkiraan.DG_Id_Perkiraan_Induk.Refresh
'Set rsMasterPerkiraan = Nothing
End Sub
Thanks.
Edited by - erc on 3/25/2004 9:30:44 PM
Saving Ink (digital Signature) To Access Database
Hello,
I have a VB6 application and I would like to add a digital signature to one of my module. I just want to create an area for them to sign (using stylus in tablet pc) , save the ink to Access database and able to load the signature to display with the rest of the record details. Can anyone show me a sample code to do this? Appreciate all helps. Thanks.
Saving Listbox Selections To Access Database
HI,
I am a newbie to VB6. I have a small project I am trying to learn on. I have 2 groups of compents on a form with 3 items in group: dirlistbox, filelistbox and a drivelistbox.
What I am trying to accomplish is in one group for the user to select the drive letter, then the directory and finally the file name, hit a button or something and have the path along with the file name stored in an access database.
In the other group, to select the directory path and save it to the access database as well without a file name.
Does anyone know what is needed to do this or point me to a "How to for beginners/dummies" url ?
Thanks
shickey
Saving Check Box Status To A Access Database
I have a simple table that has text and check boxes. When I edit a row on the form the value is not saved to the table unless I go to the next record and then save. If I save the changes prior to going to the next record the changes are not saved. How can I fix this bug?
Saving Contents Of VB Listbox To Access Database
Good evening to all,
My Visual Basic program involves the need to save the contents of a Listbox to an Access database using a Recordset Connection.
The connection is no problem but I cannot figure out the code needed to save the Listbox contents.
Any help would be much appreciated.
Thanks
SKM.
Using A DataGrid With Coded Database Access
Hello, I have been stumped on this problem for a while.
I am need of how to correctly write the code to handle access to a database for a datagrid *without* using the ado data control itself.
I have it down pat how to connect to a database via code only for other controls, but with the grid, I get errors about bookmarks or something.
This is for a program I wish to distribute later, and so cannot have the ADO control hard coded with the location of the database.
I have tried taking an ADO control, setting up the connection string, then cut and paste that connection string to the Form Load sub, so I could change it to use app.path, but leaving the connection string blank (in the properties of the control at design time) errors out.
Any suggestions to this would be greatly appriciated! Thank you for your time.
-Greg
Connecting A DataGrid To An Access Database
Hi All
Please help. I've created the following code to connect a DataGrid to an
Access database using ADO code, but the datagrid is empty at run-time? Any
suggestions?
'Add Questions to the Questions List Box
adComm.CommandText = "tblQuestions"
adComm.CommandType = adCmdTable
Set adRS.Source = adComm
adRS.Open
If Not adRS.EOF Then
adRS.MoveFirst
Set grdQuestions.DataSource = adRS
End If
Thanks
Debbie
Saving MS Access Database To A Tab-Delimited Text File
I am trying to write my microsoft access database out into tab-delimited text file.
However the following code only writes to a unicode text file, by using ADODB.Stream. I wandered if anybody could help me, by stateing how can I write to a tab-delimited text file instead.
Set mstream = New ADODB.Stream
mstream.Open
'write header
mstream.WriteText "Event Id" + vbTab
mstream.WriteText "Day" + vbTab
mstream.WriteText "Time" + vbTab
'write each record in timetable
Do While Not rsTimetable.EOF
mstream.WriteText rsTimetable("Event ID") + vbTab
mstream.WriteText rsTimetable("Day") + vbTab
mstream.WriteText rsTimetable("Time") + vbCr
rsTimetable.MoveNext
Loop
rsTimetable.Close
mstream.SaveToFile Filename, adSaveCreateOverWrite
mstream.Close
Any help would be much apreciated
Many Thanks
Jimbo
Inserting, Saving Records From Flexgrid To Database(access..)
Dear Frnds,
I M Using Ms Access And Vb.6.0.
I Want To Insert Records In Flexgrid And Saving Records Into Table..
So How Can I Use Flexgrid..
Simply, I Have To Save , Insert Data Into Flexgrid..
I M Student And I M Developing One Software On Bank Test Key S/w.
So Plz Help Me..
Plz Give Me Some Link On Flexgrid.bcz I M New To Flexgrid....
Thanx In Advace
Sweethoney
Saving Listview Items Into Access Database....[Urgent]
I have two textbox and one listview in the form(in report mode). List view contains five columns, say, SerialNumber, Products, ProductDescription, Unitprice and Amount. Listview contains many subitems. One textbox contains Customer's Name and Other Contains the Invoice number. How to save all the listview subitems in access database for corresponding customer name and invoice number. Invoice Number is the unique one in the database.??
Looking for the help,
Saracjl
Thankx.
Relations Between DataCombox And DataGrid Using Access Database
Well, my problem is basically:
I have an Access DataBase with information about schools. I built a form with 2 combobox and 1 datagrid. I can´t relationate the 2 combobox. I need:
1º - Select rows from the first combox and put only this information at the second (E.g At the first combobox (ComboCountries) I list all countries. So, when I click at the ComboCountries_click() I need to select one country and after, only the cities of that countries will appear (at the second combobox named ComboCities).
At the same time I need put in a datagrid the information of schools relationated with that 2 combox.
2º When a select one row at the datagrid, how can I create a link to another form showing the information of that selecting row?
Who can help me?
Thanks very much!
EXE Program Don't Populate Access Database Into Datagrid
Hi,
when I copy an exe file to another computer (only window2000 installed, no visual studio and no access installed), the program run but didn't populated data from Access database into the dategrid (It worked with the computer with vb and access installed). Do I need to installed some driver or component to make it work? Thanks.
Need Help With Adding Records To Access Database By Using A Datagrid
I have an Access database installed on my Windows NT4 PC.
I am accessing the database table records from a VB6 program
that I wrote. I have the "Working Model Edition" of VB6
installed on my PC.
I am displaying te contents of a user specified table with a
combination of a datagrid control and an ADO data control.
The code which loads the database table contents into the
datagrid is located in a "module" which is included
with the VB project. The display of the data works fine.
I then modified the program to add a "modification" form and
added the "appropriate" new code to the "global items module".
The modification of table records worked fine.
I then created a form and new code to handle "record additions".
The "add a new record" row is displayed at the bottom of the data
grid (i.e. a blank row with a "*"). However, when I position my
cursor into the "add a new record" row I can't type anything. I
even tried setting the ado data control mode parameter to
"adModeReadWrite" at both design time and run time. This did not
solve the problem.
Here is the code from my "global items module" which handles the
display of the datagrid.
Public Sub AddTableContents(strTableName As String)
' Display the specified table in the form "frmTableAdd"
' inside the DataGrid named "dgrAddGrid" using
' an Adodc control. This grid allows record additions.
frmTableAdd.lblTableAdd.Caption = "Contents of table " & _
strTableName
frmTableAdd.adoTableAdd.CommandType = adCmdTable
frmTableAdd.adoTableAdd.RecordSource = strTableName
frmTableAdd.adoTableAdd.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;User ID=Admin;Data Source=F:Program FilesMicrosoft Visual StudioVB98
ewBiblio.MDB;Mode=Share Deny None"
frmTableAdd.adoTableAdd.Mode = adModeReadWrite
Set frmTableAdd.dgrAddGrid.DataSource = frmTableAdd.adoTableAdd
frmTableAdd.Show vbModal
Exit Sub
End Sub
Any ideas on what I have to change in order to be able to add new records ?
TIA for your help.
Puting Data Into A DataBase (VB6, ADO, ACCESS, DataGrid)
Old in basic/vb but new to this part of database with VB6.
Have created an ACESS Database with several tabels.
Have a VB6 project with several forms.
ACESS, ADO, Jet 4.0 and DataGrid.
If I make a textbox and connect it to the database and say
DataBase.Recordset.AddNew
then I can add text into that textbox and this goes into that database.
So far no problem.
But now I want a value I have in a string, TextString, to be put into the database. In fact I have several such strings I want to be put into various Fields in the new Data.
But I am not able to.
Have tryed to put this text into the TextBox. But this does not get transfered into the database. Strange to me as if I type "manually" it does.
Maybee some settings or ---
So how can I send a textstring direct to a field in the database?
Have a nice day
Per
Code For Saving Picture In Ms Access Database Using Addo Connection?
hello everyone im using Ado connection like this
form load()
cnn.CursorLocation = adUseClient
cnn.Open "Data Source = drdg;UID=;PWD=;"
rs.Open "select * from employee", cnn
Set DataGrid1.DataSource = rs
DataGrid1_RowColChange 0, 0
then you set the database in odbc connection in control panel in windows. i have no problem in saving the file.
question:
what is the code for saving the picture in the database?
i download a sample but the connection is different
=============download sample ================
Set conServer = New Connection
With conServer
.Provider = "Microsoft.Jet.OLEDB.3.51"
.ConnectionString = "Data Source=" & App.Path & "DBPict.mdb"
.Open
End With
Set rstData = New Recordset
With rstData
.ActiveConnection = conServer
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open "SELECT * From Employees"
==========================================
===========modphoto.bas=====================
Public Sub FillPhoto(rstMain As Recordset, PFName As String, SizeField As String, picEmp As PictureBox)
On Error GoTo Handler
Dim bytes() As Byte
Dim file_name As String
Dim file_num As Integer
Dim file_length As Long
Dim num_blocks As Long
Dim left_over As Long
Dim block_num As Long
Dim hgt As Single
'me.imgPhoto.Visible = False
Screen.MousePointer = vbHourglass
DoEvents
' Get a temporary file name.
file_name = TemporaryFileName()
' Open the file.
file_num = FreeFile
Open file_name For Binary As #file_num
' Copy the data into the file.
file_length = rstMain(SizeField)
num_blocks = file_length / BLOCK_SIZE
left_over = file_length Mod BLOCK_SIZE
For block_num = 1 To num_blocks
bytes() = rstMain(PFName).GetChunk(BLOCK_SIZE)
Put #file_num, , bytes()
Next block_num
If left_over > 0 Then
bytes() = rstMain(PFName).GetChunk(left_over)
Put #file_num, , bytes()
End If
Close #file_num
picEmp.Picture = LoadPicture(file_name)
Screen.MousePointer = vbDefault
Exit Sub
Handler:
Debug.Print Err.Description
Resume Next
End Sub
Public Sub GetPhoto(filename As String, rstMain As Recordset, FieldName As String, SizeField As String)
On Error GoTo Handler
Dim file_num As String
Dim file_length As Long
Dim bytes() As Byte
Dim num_blocks As Long
Dim left_over As Long
Dim block_num As Long
file_num = FreeFile
Open filename For Binary Access Read As #file_num
file_length = LOF(file_num)
If file_length > 0 Then
num_blocks = file_length / BLOCK_SIZE
left_over = file_length Mod BLOCK_SIZE
rstMain(SizeField) = file_length
ReDim bytes(BLOCK_SIZE)
For block_num = 1 To num_blocks
Get #file_num, , bytes()
rstMain(FieldName).AppendChunk bytes()
Next block_num
If left_over > 0 Then
ReDim bytes(left_over)
Get #file_num, , bytes()
rstMain(FieldName).AppendChunk bytes()
End If
'rstEmployee.Update
Close #file_num
End If
Exit Sub
Handler:
MsgBox Err.Description
Resume
Debug.Print Err.Description
End Sub
Public Function TemporaryFileName() As String
Dim temp_path As String
Dim temp_file As String
Dim length As Long
' Get the temporary file path.
temp_path = VBA.Space$(MAX_PATH)
length = GetTempPath(MAX_PATH, temp_path)
temp_path = Left$(temp_path, length)
' Get the file name.
temp_file = VBA.Space$(MAX_PATH)
GetTempFileName temp_path, "per", 0, temp_file
TemporaryFileName = Left$(temp_file, InStr(temp_file, VBA.Chr$(0)) - 1)
End Function
======================================================
when i adopt the module and add to my file and when i save. i have error in this code "rstmain(sizefield) = file_length <---- the operation requested by the application is not supported by provider
pls everyone one help me to edit this module to my connection and also give me a code in getchunk and appendchunk. addo connection
i attached my download file.
thanks and more power to all have a nice day
Problem Saving Names And Other Personal Data To An Access Database
I have a bizarre problem. I have an app that basically generates accounts for services, linking data from multiple tables to generate an invoice. The user enters the name, address, items etc and the program does the rest. It works fine on most computers it is installed on but there are two computers where the program does not work properly.
The problem is with storing of certain fields such as Name, Address, Phone number etc. The program runs without crashing, you can enter and save the data and generate an account, but when you go to print the invoice the personal data you have entered does not print, and when you retrieve an old invoice from the database those fields are blank. Other data (items, costs etc) are saved and retrieved without hiccup. The database driver is Jet.4.0
I have installed this program on several computers and on every other installation of the program everything works perfectly. But I now have a second computer with the same problem. Even down to using the same install disk on different computers, the program works fine on one but not the other.
The only thing I can think of is there may be something in Windows XP that prevents the storing of "private" data such as name and address but doesnt affect the storing of other less "sensitive" data. However most of the computers are running XP and they work OK.
Has anyone come up against a problem like this before and can offer suggestions? I was prepared to ignore it when it only happened once but this latest occurrence has me tearing my hair out.
Regards,
Ian.
Saving Data To Microsoft Access Database ( Couple Of Questions )
Hey Guys
I trying to use Microsoft Access as my Database on my Pocket PC 2002. The only problem is that I don't know how to do my connection. Right now I'm using SQLCE but it giving me problem when I try to Insert data into the Table manually.
This are the code I use to connecto my my SQLCE database table.
Code:Import system.Data
Import system.Data.SQLCE
'Connection to the Database
Dim MyConnection As SqlCeConnection = New SqlCeConnection("Data Source=My DocumentsADP.sdf")
Dim MyDataAdapter As New SqlCeDataAdapter
Dim MyDataSet As New DataSet
'This give the Status of the user depending on the User ID enter in the
'Textbox called txtUserID
Dim Status As String
Try
MyDataAdapter.SelectCommand = New SqlCeCommand
MyDataAdapter.SelectCommand.Connection = MyConnection
Status = MyDataAdapter.Selectcommand.commandText = "Select UserStatus from Users WHERE UserID = '" & txtUserID.Text & "'"
MyConnection.Open()
MyDataAdapter.SelectCommand.ExecuteScalar()
Catch EX As Exception
lblErrorMessage.Text = (ex.Message)
End Try
MyConnection.Close()
1) How could I connect to my access Database??
2) Where would I located or transfer my Database file too on my Pocket PC??? Would I place it in My Document or some where else???
3) What type of file should I convert it to???? I know SQLCe uses .sdf.
4) What I be able to do Query with my Access Database???
5) Would I be able to Insert, Delete, Update, my Access database once it's upload to my pocket pc??
Thanks Guys
Thanks
Sincerely; Oscar Martinez
Edited by - youngOz on 8/5/2004 9:55:28 PM
Using An SQL String To Call Data From Access Database Into VisualBasic DataGrid???..n
the Situtaion:.. I am using an access database that holds dates as strings. example( 06252004 ). I am trying to use an sql string to search everything that is selected from that database table, for dates specified as a start date and end date, which are specified by the user. The results should be placed on a datagrid.
All my sql attempts have failed.
Can anyone help me peice one together, in an SQL string format, that will work in VB and be accepted by access when vb passes it to it?
Saving Datagrid Changes
Quote:
Originally posted by Thinker
The only way I can think of is by using a disconnected recordset
and only updating all changes once some kind of save or commit
button is clicked.
Is there any chance u could show me how to do the above?
Im currently using to 2 databases- one a local DB(temp) and other the main DB.
Firstly the Datagrid is pouplated with data from the Main DB. Then changes can be made on the remote DB(if exit the program the changes will disappear and return to the original data).
There is a save button on the form which allows the user to save the changes. But i cant seem to get that working.
Please help me
Thank you in advance
Saving Datagrid To MDB
I can't get the save function to work for my program. When I click the button to call the save function I don't get an error but it detects that changes haven't been made
ADO Datagrid Not Saving Changes
Hey all,
I am really having some strange issues.
I have a form with a datagrid and an ADO connection. When a button is clicked it inserts the below row with the below defaults
CODEWith Adodc.RecordSet
.AddNew
.Fields("Agent number").Value = StrAgentNumber
.Fields("Transaction date").Value = Now
.Fields("Transaction Type").Value = CbTransaction.Text
.Fields("Total Premium").Value = 0
.Fields("Tax Amount").Value = 0
.Fields("Currency").Value = CbCurrency.Text
.Fields("User Name").Value = StrUserName
.Update
End With
Saving Datagrid Records
hi guys
can anybody share on how to save a datagrid records:
here is the scenario:
i have a datagrid w/c populates datas from my SQL database now i wanted to save all the data's the populates my datagrid to an access database.
i have attached here a screenshot of my datagrid.
bst rgrds,
eByong
Saving Data From Datagrid
I have linked a datagrid to ADODC control.
Now when i enter a row in datagrid, it gets saved instantly in the database when i move to new row (I have set AllowNewRow property of datagrid = true). But what i am trying to do is use a save command button to save data from the datagrid to the database. Please let me know how can this be done.
Bhavesh Shah
(Rate this post if it helped you)
Bhavesh Shah
Kansas State University
Manhattan, KS
shah_bhavesh_in@yahoo.co.in
Creating A Database At Runtime And Saving The Database
I have a question ok i have a database i want to be created at run time how do i go about doing that in the program its a personal inventory so it has to be saved evertime things are added and updated so if any of you could help me that would be great
Exporting Data From One MS Access Database To Another MS Access Database In Visual Basic
hello friends,
i want to transfer the data from one Access database to another Access database using visual basic.
The first Access Database name is Data1
Table Name is tbldata1
fields - ID -- Number
venueID -- Number
Date --- Date/Time
RNo --- Number
SRNo --- Number
HNo --- Number
i want to transfer this data into the second Access Database -- Data2
with table name same & fields also the same
pls can anyone help me out with this problem
Regards
Girish
Saving Datagrid Values To Word Document
Hello...
I have form with DataGrid. I this DG I have a data, result of SQL query.
I would like to save this values to Word document.
I looked for some code samples but I didn't find any similar.
Any ideas?
Thank you...
Saving Text In ADO DataGrid Control To File
I am trying to save the text returned in an ado datagrid control (results of an sql query from a remote database) to file using a save button command and a common dialog control. The code I have looks like this:
Private Sub cmdSave_Click()
Dim strFileName As String
Dim strText As String
Dim strFilter As String
Dim strBuffer As String
Dim FileHandle%
strFilter = "Text(*.txt)|*.txt|All Files (*.*)|*.*"
cdMain.Filter = strFilter
cdMain.ShowSave
If cdMain.FileName <> "" Then
strFileName = cdMain.FileName
strText = DataGrid1.Text
FileHandle% = FreeFile
Open strFileName For Output As #FileHandle%
MousePointer = vbHourglass
Print #FileHandle%, strText
MousePointer = vbDefault
Close #FileHandle%
End If
End Sub
I have tried to set strText to the adodb recordset but that did not work. Any guidance or help is appreciated. Thanks.
Dave Christman
Saving Text In ADO DataGrid Control To File
I am trying to write a save function using a command button and common dialog control to save the text in a ado datagrid control (the information in the datagrid is a return from an sql query to a remote database) to a file. The function I have right now is like this:
Private Sub cmdSave_Click()
Dim strFileName As String
Dim strText As String
Dim strFilter As String
Dim strBuffer As String
Dim FileHandle%
strFilter = "Text(*.txt)|*.txt|All Files (*.*)|*.*"
cdMain.Filter = strFilter
cdMain.ShowSave
If cdMain.FileName <> "" Then
strFileName = cdMain.FileName
strText = DataGrid1.Text
FileHandle% = FreeFile
Open strFileName For Output As #FileHandle%
MousePointer = vbHourglass
Print #FileHandle%, strText
MousePointer = vbDefault
Close #FileHandle%
End If
End Sub
The problem is that the only item strText is storing (and sending) to the file is the first character in the datagrid control. I tried using a recordset instead of datagrid but that did not work. Any help is greatly appreciated.
Problem With Saving Changes To SQL Express(datagrid View)???
Hi There
I have developed a serial number DB using VB express and SQL Express.
I have a form with textboxes labels and buttons that display's the info from SQL.
I use the line of code below to save any new changes to the DB with a click of a button.eg new records, existing record changes ect , and it works fine
StatserTableBindingSource1.MovePrevious()
Me.StatserTableTableAdapter1.Update(Me.Database1DataSet1.StatserTable)
I have also placed a button on the form that displays the data in a datagridview. The problem im having is that the code above is also used in my datagridview, and does save newly added records, however when I make changes to existing records, and select my save button ,THE CHANGES ARE NOT SAVED??????
How does this line of code work fine on a normal form, and not work properly on a datagrid form?
Thank you
Datagrid1-ACCESS-SQL SELECT-Tie A DataGrid Click To Non-Indexed ACCESS Record?
This last post was "DataGrid -how do I tie a mouse click back to the database?"
I had an indexed ACCESS database and I was able to identify which record I clicked on by obtaining the record "ID" using: TheRecordID = Adodc1.Recordset("ID") - thus that identified the unique record in the ACCESS database.
The problem has a different twist ... there is no "ID" in a non-indexed database.
Since one can obtain a Recordset from a non-indexed ACCESS file, modify it and update it using, for example: Adodc1.Recordset.Update ...
It would seem that VB must knows which record is which!
There must be a way one can get this info, and know which record was clicked on.
It is easy to know which Recordset record number; but how about which ACCESS database file's record number?
Bob
Looping Throgh Datagrid, Saving Temp Information, Using Sql To Move Data RESOLVED!!
Using Pervasie Database, ODBC connection, DataGrid, and Visual Basic 6
I pull an Order from a database that has 3 records affliated to it:
custname ordernumber itemnumber shipdate
john 108005 133 2/2/04
john 108005 366 2/7/04
john 108005 569 2/8/04
The code I currently have only grabs the first record: I would like to be able to
grab the first record and then do an Insert into PsOrderDate sql statement
after it inserts grab the 2nd record and do the same insert, same for all the records
Code:
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDASQL;dsn=MULCH;uid=;pwd=;database=MULCH;"
Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "select Distinct PsOrder.OrderNumber,PsOrder.CustomerName,
PsOrder.ShipToAddress1,
PsOrder.ShipToAddress2,PsOrder.ShipToCity,PsOrder.ShipToState,
PsOrder.ShipToZipcode,PsOrder.ShipDate,
PsOrderLine.ItemNumber, PsOrderLine.Description1,PsOrderLine.Quantity from PsOrder,
PsOrderLine where ((PsOrder.OrderNumber = '" & ordernumber & "')
And (PsOrderLine.OrderNumber = '" & ordernumber & "') and (PsOrderLine.Type = 'I'))",
db, adOpenStatic, adLockOptimistic
tmpCounter = adoPrimaryRS.RecordCount ****tmpCounter is global
Dim i As Integer
Dim objFlds As Object
Set objFlds = adoPrimaryRS.Fields
i = 0
Do Until i > tmpCounter **tmpCounter is number or records (3)
Dim strOrderNumber, strName, strDate as String
strOrderNumber = objFlds2("OrderNumber")
strName = objFlds("CustomerName") <-------Not sure how to move to the next record??????
strItem = objFlds("ItemNumber")
strDate = objFlds("ShipDate")
adoPrimaryRS2.Open "Insert into PsOrderLine Values ( '" & strName & "', .....) WHERE (( PsOrderLine.OrderNumber <> ' "&strOrderNumber&" ') AND (PsOrderLine.ItemNumber <> ' "&strItem&" '))
i = i + 1
Loop
help im soo lost
Edited by - epatterson78 on 2/17/2004 2:03:05 PM
Saving Ink To Database With VB6
I've had a look at the InkEdit and InkPicture controls with a view to capturing handwritten documents on a Tablet PC within a Visual Basic application, and saving it to a SQL Server database.
The LoadFile and SaveFile options are not available to the ActiveX version (VB6) of these controls, so I am not sure how to get the content of the controls into the database. I have read that it is possible to use streaming, but am unsure as to how this is done.
Any ideas??
Saving To A Database
Hi, i'm fairly new to vb and i'm just wondering how I can get a program to save info to a database. ie. Say I wanted the user to be able to enter names and ages of certain people and then save that info so it could be accessed next time the program was run, how could this be done? Sorry if this is a nieve question but until now I have only been working with programs that don't save any info when they are closed. Any help welcome, thanks.
Saving Without A Database...
Hi there!
I was wondering if it was possible to save information about an application without the use of a database. I'd like to save user settings for my program and not store them in a DB. So far, all I've been able to do is save info into a database about the color that the user likes to use and the other various settings a user has made. Is it possible to save it directly to the program somehow?
Any help appreciated.
Thanks,
Tom
Saving To A Database
I want to save an excel file into a new access databse programaticaly in VBA.how can i do that?
sree
Saving To A Database
I want to save an excel file into a new access databse programaticaly in VBA.how can i do that?
sree
|