|
So I am using ODBC to connect to my SQL server like such:
<br />
<br />
connection = "Provider=MSDASQL;" + "Driver={SQL Native Client};" + "Server=MYSERVER;" + "Database=MYDB;" + "UID=MYUSERNAME;" + "PWD=MYPASSWORD;" + Trusted_Connection=yes;"<br />
<br />
Try<br />
Using connection As New OdbcConnection(ConnectionString)<br />
Dim command As New OdbcCommand(queryString, connection)<br />
connection.Open()<br />
<br />
Dim reader As OdbcDataReader = command.ExecuteReader()<br />
<br />
While reader.Read()<br />
station_count = reader(0).ToString<br />
End While<br />
<br />
connection.Close()<br />
reader.Close()<br />
End Using<br />
Catch ex As Exception<br />
SQLERROR = True<br />
WriteErrorLog(ex.ToString)<br />
Exit Sub<br />
<br />
End Try<br />
This is causing me a problem within my application. I wrote it using a Domain Admin which has access to the server through my SQL user, but the application needs to be deployed on a machine with much lower permission.
My question is:
1. Should I rewrite the database connection using a different method instead of ODBC
2. Is there something I can do on the server to fix this?
Thanks!
Steve
|
|
|
|
|
Why are you using the Odbc library instead of the SqlServer (SqlConnection, SqlCommand, Sqlxxxx...) specific library?
Also, if you're using TrustedConnection, it means you're using the Windows account to login to SQL Server. Specifying a username and password with SSPI (Trusted Connection = True) is pointless since it won't be used. You either specify a username and password to use (SSPI off) SQL Servers authentication, or you don't specify them and turn SSPI on to use Windows Integrated security.
You can get the various connection strings for all kinds of databases and connection options from ConnectionStrings.com[^]. There is also a small reference guide on the SQL Server connection strings here[^].
|
|
|
|
|
If I create a small custom class:
<br />
Public Class XMLNode1<br />
Private xmlHeader As String<br />
Private xmlValue As String<br />
<br />
Public Sub New()<br />
xmlHeader = Nothing<br />
xmlValue = Nothing<br />
End Sub<br />
Public Sub New(ByVal head As String, ByVal val As String)<br />
Me.propHead = head<br />
Me.propVal = val<br />
End Sub<br />
<br />
Public Property propHead()<br />
Get<br />
Return xmlHeader<br />
End Get<br />
Set(ByVal value)<br />
xmlHeader = value.ToString<br />
End Set<br />
End Property<br />
Public Property propVal()<br />
Get<br />
Return xmlValue<br />
End Get<br />
Set(ByVal value)<br />
xmlValue = value.ToString<br />
End Set<br />
End Property<br />
<br />
<br />
End Class<br />
<br />
How should i go about writing a disposal method for it?
Also, my idea of disposing a class is releasing all th eobject that class uses...Is that correct?
Please help
|
|
|
|
|
For this little class, you don't need to implement IDisposable.
You would normally implement IDisposable when your class holds onto unmanaged resources or holds onto other objects that require calling Dispose on them.
Read...[^]
|
|
|
|
|
I do have another class that uses an arraylist,xml reader, sql adapter, and sql connection.
I read about including a dispose method , but im not sure how to implement this. I guess i could just call each objects dispose method, but im curious as to add the disposal methods to my class.
|
|
|
|
|
As Dave mentioned, you generally don't need to implement IDisposable unless your class maintains unmanaged resources directly. However, if you are managing the lifetime of other managed resources that implement IDisposable you should also implement IDisposable yourself.
Take a look at this article[^] for more information.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]<</div>
|
|
|
|
|
Hello there!
I'm working with VB6 ( argh! I have no option) and I have a small problem,
My application has 6 forms and the main form posses 7 collections.
And the whole operation needs to work with those 7 collections (adding, deleting, counting and so on) in any Form.
My problem is: how to make those 7 collections Public or "Global"?
Ps.: I could do it in VB.Net but the current DLL's does not support .Net Framework yet.
Thanks in advance.
With Regards, Suguimoto
|
|
|
|
|
suguimoto wrote: orking with VB6 ( argh! I have no option)
Bummer. VB6 has been so dead for so long.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
IIRC, make the stuff Public in a Module.
But, IIRC, if you're thinking of doing this, you really need to rethink your data model/app design.
|
|
|
|
|
Actually I'm reading from a CSV file, putting into collections (like data base).
I believe that working with collections is the best way, instead of reading the CSV file everytime that the app needs to fill a listview ou delete a value.
At the moment I gave up on collections, and I'm reading the csv all the time. =/
Thanks anyway
|
|
|
|
|
Actually, I was referring to making everything "global"...
|
|
|
|
|
|
Just because you can do it, doesn't mean you should do it...
|
|
|
|
|
Hi,
how can i get the reference of existing(opened) form and manipulate its control properties like text,visbale etc on other form or within module? by doing new myForm does give reference of new instance rather existing one. Also, is there some different method to get instance in case of MDI application?
Would be greatful if I get some urgent response.
|
|
|
|
|
You've got a very bad design going.
You would have to pass these methods references to the forms that they would manipulate.
But, by doing so, you're completely trashing any and all concepts related to OOP and encapsulation of functionality.
No module should ever care about anything that is outside of its scope. Meaning, a method in a module shouldn't care that a form is using it. It shouldn't care about, nor use, the controls on any forms.
Forms should not be manipluating controls on other forms. Your forms should be exposing methods, and using other means, to tell themselves what to do to manipulate their own controls. This means your data model must support subscribers to events that you create, telling those subscribers that the data has changed. It's up to the subscribers to modify themselves in response to changes in the data.
|
|
|
|
|
I have a DatagridViewTextboxColumn. I allow word wrapping. When I am writting into the textbox, at run time, I would like to datagridview row height size to grow accordingly.
Here is my code:
Private Sub dgvDetail_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvDetail.CellEndEdit
RemoveHandler EditingControl.KeyUp, AddressOf editingControl_KeyUp
EditingControl = Nothing
End Sub
Private Sub dgvDetail_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvDetail.EditingControlShowing
EditingControl = CType(e.Control, DataGridViewTextBoxEditingControl)
AddHandler EditingControl.KeyUp, AddressOf editingControl_KeyUp
End Sub
Private Sub editingControl_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
EditingControl.EditingControlDataGridView.AutoResizeRows()
End Sub
Please help
Shay Noy
|
|
|
|
|
You're asking if you can set the size of the row WHILE you're editing the cell??
I don't know exactly how to pull this one off. The TextBox edit control won't resize itself while editing is taking place, so I don't see how you're going to get the "new" size of the control so you can set the size of the DGV row.
This is just pure speculation. You'd probably have to create your own edit control from scratch. You'd have to maintain the current size of the textbox while editing and have two-way communication between your control and the DGV so it can maintain the row size when the textbox size changes.
|
|
|
|
|
Hi,
I would like to have users read a pdf manual in my vb program. They can save the
unicode of text of a pdf file (text) into a database (wich should be done through searching a text in pdf programmatically). The pdf may be in anylanguage.
If somebody could help me on my way how to display a pdf file in my vb
program it would be a big step forward in my little project.
Thank you for your time...
|
|
|
|
|
You'll need a third party component, like Adobe Acrobat Reader or PDFnet[^], to read the PDF file and render it.
There is no built in support for PDF files in the .NET Framework.
|
|
|
|
|
Hi all,
I am developing OPC Client in VB.net. I have developed the code and reading OPC Items on Sampling as well as event based (OnDataChange). When I am working with local machine then my code works fine with both Sampling as well as OnDataChange, but when I am trying to read data from Remote OPC Server then Sampling works fine but I am not able fetch data on event based process. I am able to connect to the OPC Server but when i am adding subscription to it then i am getting error.
HRESULT : 0x80040202.
Public NetCredentials As New System.Net.NetworkCredential
Dim connectdt As Opc.ConnectData
Public WithEvents Subscription As ISubscription = Nothing
Public State As New Opc.Da.SubscriptionState
State = New Opc.Da.SubscriptionState
State.Active = True
State.UpdateRate = 500
Subscription = OpcServer.CreateSubscription(State)
results = Subscription.AddItems(Items)
AddHandler Subscription.DataChanged, New DataChangedEventHandler(AddressOf OnDataChange) ' Here is the error.
I appreciate if anybody suggests some solution.
Thanks in advance.
Prashant Khonde
Software Engineer
Navi Mumbai India
|
|
|
|
|
THis is possibly caused by a known issue, depending on which version of .NET you're using. Read this.[^]
|
|
|
|
|
I am using VS2005 with .net 2.0. This issue is something related to securities of Client and Server machines.
I am struggling with this issue from last 1 week and not able to resolbe the same.
Any suggestions ??????
Prashant Khonde
Software Engineer
Navi Mumbai India
|
|
|
|
|
Hi,
I need source code for importing data by character wise from excel to sql server using vb.net or C#. It is really very urgend. I hop u all help me.
Thanks in advance.
With Regards,
A.kamar
|
|
|
|
|
Noone is just going to hand over source code to do this. You have to write the code yourself, then we'll be happy to help you with any problems. But, just comming here asking for someone to do your work for you... that's just not going to happen.
This[^] is the best anyone is going to do to get you going.
|
|
|
|
|
kamarudeen wrote: I need source code
No.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|