|
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
|
|
|
|
|
Hi Michael
I'm using Access but I don't store this type of info in it anyway. Basically my app is an add-on extending an accounting software with its own proprietary db.
My app is using a separate db to store some info and i don't need to keep the customers etc. on my side.
Hence these classes are written as wrappers for a very !!!UGLY!!! sdk class library supplied with the software.
And at this point it's a matter of principle for me to understand why this issue arises with collections of classes in .net.
If anyone could throw my way some code with a class collection I would greatly appreciate it.
I just want to know what I’m doing wrong.
Thanks in advance
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!
|
|
|
|
|
Ok Im Looking Through and trying to find where you call your refresh...
It seems to me that its passing the New Customer in Correctly... but the Refresh refreshes all of the info in the list to the newly saved customer... Tell me what you think while I try and write this ...
I use Stored procs for all of my database access so this is new to me as well.. so go easy on me but, i will give this an attempt and if anything everyone else will eb able to correct me and give you more insight.
Michael
|
|
|
|
|
Hey there.
Don't kill me but...
I'm not that familiar with the list...of collection. If ever I need to do this kind of thing I just use a Collection variable. The only thing I can see is that the call to Sub New in you Refresh is comehow calling across all your clsSalesrecords held in mem. Sounds insane. Anywho, is there a need to use the List type? just slap 'em all into a simple collection, and see if that makes a difference. If so, at least you'll know exactly where it's happening, though why is beyond me.
|
|
|
|
|
What you have should work with the exception that _Records never gets created.
<br />
private _Records As Generic.List(Of clsSalesRecord)<br />
should be
<br />
private _Records As New Generic.List(Of clsSalesRecord)<br />
Where is the code that is calling the Refresh method?
Mike Lasseter
-- modified at 17:29 Friday 21st July, 2006
|
|
|
|
|
Hi Guys,
First off all, thanks for all the replies.
Like i said before the sdk is UUUGLY! so the refresh method would make no sense to you guys anyway without the supporting docs. In short all it does is assign Nothing to the Customer class and loop through something that was meant to be a collection in the SDK classes etc.
In any case you're fixating on the wrong thing. The collection either way i declare it generates the exact same issue. I even tried this with a structure called Customer instead of a class and the structure would have a private var to store stuff. The exact same ..it happenz!
As Michael said i pass the Customer in correctly, the collection, God love it!, is properly initialized and gets its first element fine. BUT the moment i Nothing the Customer class instance that was passed BYVAL to the frigin collection, the instance of the class in the collection gets Nothinged as well.
HOW THE ... ... .... ......... IS THAT POSSIBLE?????????????
The instance that gets Nothing is outside the scope of the sub or the collection class, and even if it wasn't it's passed BYVAL for crying out loud.
That’s my current concern!
I really appreciate your assistance but I will havta end my life now...probably very violently!
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 don't think you understand how ByVal works when using objects/classes.
For objects (that is, reference types) ByVal means that the function being
called cannot overwrite the *reference* to the object instance which is
actually passed in the parameter variable. But it does not prevent the
callee to alter properties on the instance.
ByRef, on the other hand, enables the callee to overwrite the reference
itself and therefore substitute the original object instance with another
one.
Mike Lasseter
-- modified at 8:30 Monday 24th July, 2006
|
|
|
|
|
Hi Friends,
I am creating an application in vb.net which will be download all files of latest date from FTP server.
I have found all files from FTP server through my code.But I do not understand how to download files from FTP Server to client location.
If any one can help me that will be really appreciate.
It's very urgent.
Regards & Thanks
Sunil
|
|
|
|
|