|
Hi,
I am stuck with this problem for weeks. To put it simple, for example, I have two related tables in MS SQLServer 2000 express: Author and Publications. The Publications table has a foreign key author_id and its primary key is of type int, which Identity is set to "Yes", Seed is set to "0". After playing with the tables for a while, when I use the addnew() to add a new record in the "Publication" table, the index number of the author_id always give me a wrong number: 2 more than the desired number. For example, I have the last record with author_id = 100 in my database, when I try to add the new record, it always give me the author_id of 103. So after update(), there are two records shown here, one with author_id 101 and the other 103. Of course the 103 is wrong, and if I keep working with this fake record, an error with occur. I have to close the form and reopen it, then only the desired record with author_id 101 shown up. The following is the addnew function I used:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Me.BindingContext(DsAuthorPub, "Author.AuthorPub").EndCurrentEdit()
Me.BindingContext(DsAuthorPub, "Author.AuthorPub").AddNew()
End Sub
Could anyone please give me some hint why I have this problem and how to deal with it?
Thanks alot,
VBDotNetNewbie
VBDotNetNewbie
|
|
|
|
|
Sorry for the confusion of the question I just posted, what doesn't show right is the "publication_id" not the "Author_id".
VBDotNetNewbie
|
|
|
|
|
Someone to help me with a vb6 code that can save Picture into an access/SQL Server database.
Presently i save the Picture Path as a string inside the database table but i want the actual picture to be saved as part of the table.
What is the implication of saving picture inside access table?
t.aransiola
|
|
|
|
|
Not Sure on the implication or the how to do the above task... what are you trying to use this picture int he database for? I might have a few Ideas on how to accomplish the same thing without the hastle of figuring this out.
Michael
|
|
|
|
|
i want to save the picture inside the database because saving the picture using the picture filename, once the picture filename or pathname is tampered with the picture will not show on my vb form
i have done this in vb.net 2003 and is working, is just that i have a vb6 application that i want to do the same
thanks
t.aransiola
|
|
|
|
|
Search for BLOB's at www.msdn.microsoft.com. I'd do it for you but I'm here on my mobile I've had the same question before and that's the answer I got.
|
|
|
|
|
i dont know how to do it in vb but in vb.net if u want to store picture in Sql or access , u first have to convert ur picture in binary format , then store it in sql / access in [image] field. and to vice-versa to show in ur form.This is all u have to do to store pics in database.
I think it works for u .
|
|
|
|
|
i have created a client/server application that stores some data to the databade @ the server,the problem is whenever i try to install the application on another system it shows an unhandled exception & states tht the particular field cannt be found but reconfiguring the data adapters solve the problem. How to overcome this situation.?????
|
|
|
|
|
you can use an application .config file to specify the location of the database then refer to the application .cofig file when pointing to the database with your connection string. To get to the app.config file ... right click, add new item, app.config... then open it you should see something like mine below. The easiest way to get a good connection string for <add key...="" is="" to="" use="" your="" data="" adapter="" and="" just="" copy="" the="" conn="" string="" in="" field="" connection="" string.
hope="" this="" helps="" .
ex.
<?xml="" version="1.0" encoding="utf-8" ?="">
<configuration>
<appsettings>
<add key="odaCustomer.ConnectionString" value="Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Database Password=;Data Source="\\Sfssv01\userapps\SFS OTR Rate Prg\dbsharp.mdb";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider="Microsoft.Jet.OLEDB.4.0";Jet OLEDB:System database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False">
<add key="mskPhone.Visible" value="True">
Ex. Conn String (Access) "if need another database tell me..."
'Place This in a Module
Public cnnRate As New OleDb.OleDbConnection
Public odaCustomer As New OleDb.OleDbDataAdapter
Public Sub Connect()
Try
cnnRate.ConnectionString = _
System.Configuration.ConfigurationSettings.AppSettings("odaCustomer.ConnectionString")
Catch ex As Exception
MsgBox(ex)
End Try
Michael
|
|
|
|
|
Also ... if you have plans for deployment and other issue's let me konw so i can tell you about other small details that might get in your way. The idea above allows for configuring the connection string at any point after installation... you can simply open the app config file after install with notepad and change the small section refering to connection string. Then its fixed
Michael
|
|
|
|
|
hi,
can you guys suggest me an alternative for checking whether an object is Nothing ?
i don't want to use the below code...
if Not objTemp is Nothing then
.
.
.
end if
thanx!
Najmun
|
|
|
|
|
If IsNothing(objTemp) Then
MsgBox("I found another way of testing nothing")
End If
Rizwan Bashir
|
|
|
|
|
We just upgraded from VS2003 to VS2005 and we've been having some conversion errors.
For this line of code:
origDV.RowFilter = String.Format("Weight < {0} OR Diameter <{1}", Leg.LookupTotalWeight(), Leg.LegWidth) ' + CStr(Leg.LookupTotalWeight()) + " OR Diameter <" + CStr(Leg.LegWidth)
We are getting the error 'Cannot convert System.Decimal to System.SqlTypes.Double'
Any ideas on how to correct this? We're not finding a lot of information.
|
|
|
|
|
Converting from decimal to double is a narrowing conversion with potential for losing precision but not information about the converted value. It's bad casting but it won't throw you an exception. Try declaring your decimal value as double instead.
|
|
|
|
|
I was wondering the best way to go about importing the read only property to the mask edit boxes from VB6. I would like to know the same about a Combo Box as well... If I could get teh basic Idea for adding the Read Only Property to a control I could figure the rest out on my own.
|
|
|
|
|
hi,
I have small query, i want the database server to send a message to the client application on updation of certain records on the ms sql database server.
Plz help me in resolving this issue.
Thanks in advance.
Riz
|
|
|
|
|
|
Hi,
Can you plz elaborate this concept and let me knw if there are any possible sites that will provide me with this information.
Waiting for an early response from you.
Thanks in advance,
Riz
|
|
|
|
|
|
Hi Guys,
Stupid question!
I got a collection class, Customers, that should store classes of type Customer. Simple enough task. BUT!!! for some reason after I add my first customer class to the collection class every time I instantiate a new customer class the customer that is already in the collection gets the same data as the new customer. So in the end I get a ton of classes in the collection identical to the last class added.
The customer class has a private structure to hold customer info and the add method of the collection class passes the new customer class directly into the collection.
The new method of the Customer class gets the params byval and fills the structure so i don't how the previous instances of the class already in the collection assume that they need to change.
The whole thing is done vb2005.
Any kind of light shed on the issue would be greatly appreciated
The perfect code is always in your head...it just a matter of how hard you bang your head against the wall to get it out!
|
|
|
|
|
Hard to answer without some code. Do you have some Shared fields within that customer class?
|
|
|
|
|
Hi Robert
Nope nothin is shared. All vars are private and if anything is passed to the Customer class it's byval.
Here is the Customer class:
<br />
Public Class clsSalesRecord<br />
Private Record As Object<br />
<br />
Public Sub New(ByVal SalesRecordObject As Object)<br />
Record = SalesRecordObject<br />
End Sub<br />
<br />
Public ReadOnly Property Reference() As String<br />
Get<br />
Return Record.id<br />
End Get<br />
End Property<br />
End Class<br />
Here is the collection class:
<br />
Public Class clsSalesRecords<br />
<br />
private _Records As Generic.List(Of clsSalesRecord)<br />
<br />
Public Sub Refresh(byval Record as object)<br />
_Records.Add(New clsSalesRecord(Record))<br />
End Sub<br />
HELP!!!
The perfect code is always in your head...it just a matter of how hard you bang your head against the wall to get it out!
|
|
|
|
|
Are you always passing the same Record object into the Refresh sub? If yes then surely all your customers will point to the same reference...
|
|
|
|
|
I appreciate the vote of confidence!
No!!!
Thats the thing, when the first class is added to the colection it has it's set of values. Then when i instantiate a fresh Customer class with a new record object and even before the new customer class is added to the collection the class already in the collection changes it's values to those of the fresh Customer. (My bad! I don't think I made this clear before )
So it seems as if the collection is holding onto a ref of the customer class. This in turn is strange as you can see that Customer classes are passed byval into the collection.
Class params passed byval should preserve the structure of the reference class but not be references themselves....No?
Thanks for givin me hope
The perfect code is always in your head...it just a matter of how hard you bang your head against the wall to get it out!
|
|
|
|
|
I was wondering what DB are you using? I might be able to give you an alternate way of looking at this if I knew...
Michael
|
|
|
|