|
con.Provider = "Microsoft.Jet.Oledb.4.0"
con.ConnectionString = "Data Source = " & mdbPath & ";Jet OLEDB:Database Password=1234"
con.Open()
Shay Noy
|
|
|
|
|
Hi i am having an error message thrown when I wish to update my database. I call a sub procedure called Savechanges(which definately works because it is straight from a textbook and has been used in various projects I have done) for the rowChanged event of the datagridview which I am using to edit information. I might be calling saveChanges() to often but thats due to the fact that I don't know where to call savechanges for the datagridview? My datasets and adapters are all generated and I have looked at the select statement for the table adapter which has the problem and the select statement is correct. The datatypes are also correct for the various fields. Is there anywhere else I can check to see why the error is happening? Where should I call saveChanges for the datagridview for optimal performance? I am using VB.NET 2005 in a single user environment. thanks
Mr Oizo
|
|
|
|
|
Do you have a GUID on each row?
Sometimes if you don't have a GUID on a row it is not clear which record is being updated and the database update falls over.
You always pass failure on the way to success.
|
|
|
|
|
G.....I have never heard of a GUID. How would I put one on each row? I'll try search on the net so long tho. Thanks
Mr Oizo
|
|
|
|
|
A GUID is a "Globally Unique Identifier". Basically a 128-bit number used to identify objects. A GUID is a bit too "heavy" for a database key.
Read up on "Primary Key[^]".
|
|
|
|
|
Not so much a GUID, but a Primary Key for each record in the table is REQUIRED to use the Adpaters.
|
|
|
|
|
the table is a table called "SONG". In this table for each song listed is a unique (autogenerated number) field called "SongID". This table also has many to one relationship with a table called "GENRE"(One genre can have many songs) and another many to many relationship with a table called "CATEGORY"(a song must belong to one or more categories and a category consists of many songs). Anyway these relationships are defined in the access database and automatically in the .xsd file for my solution. (Genre table has a primary key named "genreName" which is also a foreign key in the table song) this is all correct as far as I know. At the moment I am only running updates for the fields in the song table which is theoretically a child table of both CATEGORY and GENRE. What might the problem be?
Mr Oizo
|
|
|
|
|
Okay - there is the issue.
You mentioned Access database - well you need a unique index in order to be able to update a table in Access - or at least I always have needed on with Access databases and VB .NET .
I mentioned GUID as it is the easiest way of ensuring you have a completely unique key - actually I have come across non unique GUIDs in my career.
For a less heavy option, GUIDS can take space in your table, you could create a composite key i.e. a key made up of multiple fields such as artist, album and songname.
However you could still have issues which is why in my opinion if space is not an issue a GUID is very useful.
You always pass failure on the way to success.
|
|
|
|
|
Thanks for the reply....My song table does have a unique ID. It is an autonumber sequentially generated field named songID. Do I need to manually write an update statement to update the database? I thought the autogenerated statements would be fine? My table adapters and datasets are all auto generated and my datagridview uses the SONG table as its DataMember. I would of thought that all i need to do is update the fields in the datagridview and then record the changes back to the database? By using
Public Sub SaveChanges()<br />
<br />
'this Sub is responsible for recording changes back to the database<br />
<br />
Dim dsUpdates As dsLibraryNewest<br />
<br />
Try<br />
dsUpdates = CType(DsLibraryNewest.GetChanges(), _3rdYearProject12Aug.dsLibraryNewest)<br />
<br />
If Not (dsUpdates Is Nothing) Then<br />
'these are various adapter for the six various tables <br />
modbdaSongNewest.Update(dsUpdates)<br />
modbdaCategoryNewest.Update(dsUpdates)<br />
modbdaGenreNewest.Update(dsUpdates)<br />
modbdaAlbumNewest.Update(dsUpdates)<br />
modbdaCategorySongNewest.Update(dsUpdates)<br />
modbdaAlbumSongNewest.Update(dsUpdates)<br />
<br />
<br />
DsLibraryNewest.AcceptChanges()<br />
End If<br />
<br />
Catch ex As System.Exception<br />
<br />
' MessageBox.Show(ex.Message, "Error", _<br />
'MessageBoxButtons.OK)<br />
<br />
End Try<br />
<br />
End Sub
Mr Oizo
|
|
|
|
|
As far as I know you do need to write an update query as the Access table is not bound to the dataset.
What happens in creating a dataset is that VB takes a copy of your Access table and displays this copy.
Here is a link[^] to a good example of how to update an access database.
I hope it helps.
You always pass failure on the way to success.
|
|
|
|
|
greetings to you all,
guys i need your help very badly.. on how to create a dynamic textbox object in runtime... using VB.NET 2005
the code below suppossedly can display 5 textbox,
but sad to say i cannot see any textbox in my form.
Can someone help me on this:
For xcnt = 0 To 4
Dim text As New TextBox
text.Visible = True
text.Location = New Point(33 + xcnt, 27)
text.Size = New Size(104, 21)
Next
pls help here... thank you so much....
links/codes are highly appreciated..
-- modified at 6:21 Monday 24th September, 2007
start a new beginning in every ending; thats what life for......
|
|
|
|
|
Main problem is that you are not adding text boxes to Forms control collection.
Try following code –
--------------------Start Code---------------
Dim xcnt As Integer
Dim x As Integer
x = 20
Dim txt As TextBox
For xcnt = 0 To 4
txt = New TextBox
Me.Controls.Add(txt) ‘you were missing this line
txt.Location = New Point(33 + x, 27 + x)
x += 25
Next
-------------------Code End---------------------
I hope this helps .
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
thank you sir dave, your help is very highly appreciated..
looking forward to you soon, many thanks..
start a new beginning in every ending; thats what life for......
|
|
|
|
|
hi,
how to convert Byte to IntPtr ?
Thanks & Regards
|
|
|
|
|
|
Have a look at the GCHandle class, it will tell you how to pin an object (such as a byte array)
to rpevent the GC from reshuffling it, and it will give you an IntPtr to it. Don't forget
to call Free() when you're done!
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Dear All ,
We have Developed a Application with .net Remoting, that works fine but my problem is when any exception occurs in my business login(Remote Object ) My application gets terminated and my Clients accessing the remote object gets affected , is there any method to handle this situation .
|
|
|
|
|
put a try catch in you're remote object then when an exception occurs send a message to the clients (in the catch of finally of the try catch) who then can shut down or do something else (this will only work offcorse if the exception isn't one that there is no connection)
I'm not that experianced in remoting so there could be a better way
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
Hi all,
im new to vb .Net but loving it
can anyone help me, i want to specify a path in a textbox and then have a loop (not sure if i need a for each loop) look at each subdirectoy and return the name of the directories one by one in a messagebox.
i know its simple but i need to start somewhere
thank you
|
|
|
|
|
Use Directory.GetDirectories passing in the directory you want to start your search from.
Dim returnPath As String() = Directory.GetDirectories(txtDirectory.Text)
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thank you,
i put this onto the button and altered it slighty
Dim returnPath As String() = System.IO.Directory.GetDirectories(txtdirectory.Text)
and that seems ok, dont i need a loop though to display each directoryname in turn?
thanks
|
|
|
|
|
If you like to click OK and close a lot of MessageBoxes go ahead and put it in a loop...
Otherwise string.Join all filenames (with Environment.NewLine) and show them all at once.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
yes i want to click ok to a lot of boxes, because then i want to progress the code from passing each one into a messagebox into something else.
please can you help?
thank you
|
|
|
|
|
Hi,
I have a gridview control in which i have added two comboboxes(cmbCity,cmbPincode) at the runtime.I populate the cmbCity combobox from the database at the form load event.
Now my requirement is that when ever i select an item from cmbCity ,the relevent picode should be automatically populated into cmbPincode.
Please help me out how to handle the cmbCity_SelectedIndexchanged event inside a gridview control..
Pradip kishore
|
|
|
|
|
Here is the problem:
I use Adodc control in vb6.0 to access sql server,everything works fine until when the network failed.
the code simply like this:
On Error ErrHandle
Adodc1.ConnectionString = "Provider=SQLOLEDB.1;user id=sa;password=123456;initial catalog=test;data source=192.168.1.23\SQLEXPRESS;Connect Timeout=30"
Adodc1.Recordset.Properties("prompt") = adPromptNever
Adodc1.RecordSource = "select *from admin"
Adodc1.Refresh
'other code
ErrHandle:
'do nothing
when the code run to Adodc1.Refresh,it pop up an error dialog with message "[DBNETLIB][ConnectionOpen (Connect()).]SQL Server Not Exist or Access Denied"
It's normal that you can't access data base when the network is not working,but since my program is runing at the server host I don't want it to click the dialog all the time when it can't connect to sql server.
So is there some way that can avoid the error dialog? and let it goto ErrHandle Section
I have being run into this problem for several months, any advice would help.
thank you.
polarstar
-- modified at 4:02 Monday 24th September, 2007
|
|
|
|