|
You pass the instance of your Login class to this method so it can use the information inside it to create the connection string.
Also, change the m_User and m_Password fields to Private, not Public. You're aslready exposing the fields as public Properties so you don't need to expose them twice.
Imports Database_Class
Imports System.Data.oracleClient
Public Class Connection
Public Shared Function GetConnection(ByVal credentials As Login) As OracleConnection
Dim connectionString As String = _
String.Format("Data Source = PIDBDEV; User ID={0};Password = {1};Unicode = True;", _
credentials.UserName, credentials.Password)
Return New OracleConnection(connectionString) Return New OracleConnection(connectionString)
End Function
|
|
|
|
|
wow thanks dave...the only thing is now when I am creating a new instance of the connection how do I pass the credentials to the function?
This is how i was doing it when I had the userID and password hardcoded into the connection string...
Dim newConnection As OracleConnection = Connection.GetConnection
this doesnt work:
Dim newConnection As OracleConnection = Connection.GetConnection(credentials as login)
i am trying to understand how to use properties...you have been a great help with the last issue.
Erica
|
|
|
|
|
OK, I would seriously suggest picking up a book on VB.NET and working through it. What your asking is a basic concept you find covered in any beginners book.
You have to create an instance of the Login class, fill in the properties, then pass it to the GetConnection method:
Dim myLoginData As New Login
myLoginData.User = "username"
myLoginData.Password = "password"
Dim conn As OracleConnection = Connection.GetConnection(myLoginData)
|
|
|
|
|
Hi guys,
I added icons to an imagelist which i then associated with a treeview control. The original icons have a transparent background and are of relatively good quality pictures, however when i run my system, they look very grainy at the edges and have a blue border around them when they appear in the treeview at runtime. i used the original icon size (16X16) and a color depth of 32bits. Is there something else about this control and icons or maybe is it haunted?
Thanks a lot for your assistance.
Regards
|
|
|
|
|
Hi,
I have a .NET DLL written in VB 2005. I have to run this in a VB6.0 application.
I've created the .TLB file for the DLL in VB 2005, and successfully imported this reference to the vb6.0 app. All works well on my development machine. However, my problem is distribution. On Package And Deployment through vb6.0, all is transferred successfully to a new machine, but when I run the vb6.0 app, I get the Error:
"Run time error 429. ActiveX component can’t create object"
Any ideas?
Thanks,
Andy
|
|
|
|
|
I think that you must check whether the class library is deployed with the application and it is registered on the other machine. May be your setup project doesn't register class library by default ?
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Thanks for this.
The DLL is deployed by the setup.exe, however it's likely not registered during that process.
Could yoy advise on how to register a DLL on the new machine?
Thank you!
Andy
Actually, it's okay - I've found the Regasm tool! All's well.
modified on Tuesday, December 11, 2007 7:37:28 AM
|
|
|
|
|
I can tell you the command to install some COM component (ActiveX), but I have no experience on how to call external exe from Setup Deployment Project. The command used to register any COM component is -
regsvr32 /i <complete path="" of="" com="" dll="">
Hope this helps.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
RegSvr32 works for COM-based .DLL's only, NOT on .NET .DLL's.
RegAsm works for .NET DLL's, registering them so they can be consumed by COM clients. In the old VB6 Setup and Deployment project, you'd have to customize the project to run the RegAsm as an external app.
|
|
|
|
|
Hi,
anyone know of a function already in .Net to return the monthend date of a specified date?
If I have a date, 30 April 2007, and call:
myDate.AddMonth(1)
It will return 30 May 2007, but thats not the monthend.
Anyone know?
|
|
|
|
|
DateTime.DaysInMonth
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi all
i m trying to use datagridview to display some data from database and i am trying this with out using dataset.
what exactly i m trying is find some alternative from which i can fill datagridview directly with dataadapter or some thing like that.
the moral is, i need to done my work (the loading) in just less than a second.
does some have any idea
thanks in advance.
help everyone
Falling down is not defeat...defeat is when u refuse to get up...
|
|
|
|
|
Hi,
The following code demonstrates one of the ways to fill up DataGridView without using DataSet.
BEGIN CODE
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class Form1
Inherits System.Windows.Forms.Form
Private buttonPanel As New Panel
Private WithEvents songsDataGridView As New DataGridView
Private WithEvents addNewRowButton As New Button
Private WithEvents deleteRowButton As New Button
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
SetupLayout()
SetupDataGridView()
PopulateDataGridView()
End Sub
Private Sub songsDataGridView_CellFormatting(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) _
Handles songsDataGridView.CellFormatting
If Me.songsDataGridView.Columns(e.ColumnIndex).Name = _
"Release Date" Then
If e IsNot Nothing Then
If e.Value IsNot Nothing Then
Try
e.Value = DateTime.Parse(e.Value.ToString()) _
.ToLongDateString()
e.FormattingApplied = True
Catch ex As FormatException
Console.WriteLine("{0} is not a valid date.", e.Value.ToString())
End Try
End If
End If
End If
End Sub
Private Sub addNewRowButton_Click(ByVal sender As Object, _
ByVal e As EventArgs) Handles addNewRowButton.Click
Me.songsDataGridView.Rows.Add()
End Sub
Private Sub deleteRowButton_Click(ByVal sender As Object, _
ByVal e As EventArgs) Handles deleteRowButton.Click
If Me.songsDataGridView.SelectedRows.Count > 0 AndAlso _
Not Me.songsDataGridView.SelectedRows(0).Index = _
Me.songsDataGridView.Rows.Count - 1 Then
Me.songsDataGridView.Rows.RemoveAt( _
Me.songsDataGridView.SelectedRows(0).Index)
End If
End Sub
Private Sub SetupLayout()
Me.Size = New Size(600, 500)
With addNewRowButton
.Text = "Add Row"
.Location = New Point(10, 10)
End With
With deleteRowButton
.Text = "Delete Row"
.Location = New Point(100, 10)
End With
With buttonPanel
.Controls.Add(addNewRowButton)
.Controls.Add(deleteRowButton)
.Height = 50
.Dock = DockStyle.Bottom
End With
Me.Controls.Add(Me.buttonPanel)
End Sub
Private Sub SetupDataGridView()
Me.Controls.Add(songsDataGridView)
songsDataGridView.ColumnCount = 5
With songsDataGridView.ColumnHeadersDefaultCellStyle
.BackColor = Color.Navy
.ForeColor = Color.White
.Font = New Font(songsDataGridView.Font, FontStyle.Bold)
End With
With songsDataGridView
.Name = "songsDataGridView"
.Location = New Point(8, 8)
.Size = New Size(500, 250)
.AutoSizeRowsMode = _
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders
.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single
.CellBorderStyle = DataGridViewCellBorderStyle.Single
.GridColor = Color.Black
.RowHeadersVisible = False
.Columns(0).Name = "Release Date"
.Columns(1).Name = "Track"
.Columns(2).Name = "Title"
.Columns(3).Name = "Artist"
.Columns(4).Name = "Album"
.Columns(4).DefaultCellStyle.Font = _
New Font(Me.songsDataGridView.DefaultCellStyle.Font, FontStyle.Italic)
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
.MultiSelect = False
.Dock = DockStyle.Fill
End With
End Sub
Private Sub PopulateDataGridView()
Dim row0 As String() = {"11/22/1968", "29", "Revolution 9", _
"Beatles", "The Beatles [White Album]"}
Dim row1 As String() = {"1960", "6", "Fools Rush In", _
"Frank Sinatra", "Nice 'N' Easy"}
Dim row2 As String() = {"11/11/1971", "1", "One of These Days", _
"Pink Floyd", "Meddle"}
Dim row3 As String() = {"1988", "7", "Where Is My Mind?", _
"Pixies", "Surfer Rosa"}
Dim row4 As String() = {"5/1981", "9", "Can't Find My Mind", _
"Cramps", "Psychedelic Jungle"}
Dim row5 As String() = {"6/10/2003", "13", _
"Scatterbrain. (As Dead As Leaves.)", _
"Radiohead", "Hail to the Thief"}
Dim row6 As String() = {"6/30/1992", "3", "Dress", "P J Harvey", "Dry"}
With Me.songsDataGridView.Rows
.Add(row0)
.Add(row1)
.Add(row2)
.Add(row3)
.Add(row4)
.Add(row5)
.Add(row6)
End With
With Me.songsDataGridView
.Columns(0).DisplayIndex = 3
.Columns(1).DisplayIndex = 4
.Columns(2).DisplayIndex = 0
.Columns(3).DisplayIndex = 1
.Columns(4).DisplayIndex = 2
End With
End Sub
<STAThreadAttribute()> _
Public Shared Sub Main()
Application.EnableVisualStyles()
Application.Run(New Form1())
End Sub
End Class
END CODE
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
eyes2007 wrote: i need to done my work (the loading) in just less than a second.
That depends on how much data you're talking about, where the data is stored, what kind of database it is, ..., not to mention that the DGV itself isn't known for it's speed in creating rows.
|
|
|
|
|
I have started to programming in Visual Studio.NET 2003 and specifically in Visual Basic of this Studio.
I have a problem with the data I want to export from a picture box.
I set a background image in a picture box and after writing some code I manage to overlay another image in the background image(in the same picture box).
Finally, I manage to show in the picture box the two different images (one above the other) and I want to save (export) the final image as a new “.bitmap” image.
Can anyone help me?
Thanks in advance
|
|
|
|
|
The background is a Image - object, and in this class you've got the Save method (just use <code[yourimage].image.save("c:\test.bmp")> to save it as a Bitmap)
|
|
|
|
|
Thank you very much. I will try it!
|
|
|
|
|
First of all, please don't spam the whole site.
The Bitmap class has a Save method. However, if the PictureBox has a background image and you're just setting another image above it, the image above it is all you will save.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks a lot! So, I'll try the Save method.
|
|
|
|
|
Is there anybody out there who could help me please.
I am trying to make use of the Transactionscope to implicitly create a transaction. This transaction should roll back when a condition is not met. It doesn't seem to work for me even though i have started the msdtc service. My function inserts a row in an oracle database using the DI.CreateTemplate. Now i want it to roll back the insert when the Attach_ID_To_Invoice_Batch process is not sucessful.
Dim DI As New DataLayer.Invoice
Dim intRetVal As Integer = -1
Dim options As New Transactions.TransactionOptions
options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
Try
Using scope As Transactions.TransactionScope = New Transactions.TransactionScope(Transactions.TransactionScopeOption.Required, options)
'If Not IsDoumentAllocated(EntryID) Then
intRetVal = DI.CreateTemplate(oTemplate, strTemplateName, enumTemplateType, UserID, -1, -1, "")
If intRetVal <>0 Then
If Attach_ID_To_Invoice_Batch(intRetVal, EntryID) Then
scope.Complete()
Else
intRetVal = -2
End If
Else
intRetVal = -1
End If
'End If
End Using
Catch ex As Exception
Return intRetVal
End Try
Could somebody please go through this code and let me know what i am missing.
|
|
|
|
|
hey, i am having some trouble with my Hotel billing application form my visual basic 2005 book. I have completed the assignment halfway through, i just need help with some of the more harder coding i guess you could say. this doesn't include any databases or anything either.
It is case 5 from the programing assignments in chapter 8:
I have to design a hotel billing assignment for a cancun resort in Mexico.
The purpose:
the application will calculate the hotel cost and convert the bill into mexican pesos or american dollars based on the customer's nationality.
Other Info:
A combo box requesting the type of room:
King Suite ($280)
2 Queen Beds suite ($310)
King Standard Room ($235)
2 Queen Beds Standard Room ($255)
i have the entire interface completed, i need help with the code for converting american dollars to pesos. here is what i got that is completely wrong, i don't even think this is the right procedure, i do no it is way to short... i really need help with this
AmericanDollars = Pesos * 0.1
after that is converted, i need to add up the rooms like,
if people stay in the King Suite for 7 nights it will cost... $300 or something. and i don't no what source i need to write.
can someone help me with making these proceddures?
thanks alot ...seroiusly
/J-Man\
|
|
|
|
|
You need to store the prices for each item, probably in the value property of the combo box item. Then you need to multiply that by the number of nights.
AmericanDollars = Pesos * 0.1
Assuming that Pesos contains the price in Pesos and AmericanDollars is a variable to hold the US$ price, then the only possible problem here is that the conversion may not be 100% accurate. The code is fine.
I'd do the conversion at the end, after you work out the total price.
TotalPrice = RoomCost * NumberOfNights
That's really it, you just need to fill the blanks.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
ok well i have this in the cod,e i can't seem to fine what is missing?:
Dim Numberofnights As Decimal
Dim introomtype As Integer
Dim roomcost As Decimal
Dim totalprice As Decimal
Dim americandollars As Decimal
americandollars = Pesos * 0.1
TotalPrice = RoomCost * NumberOfNights
' it needs to print the total(s) here:
Me.lblFinalTotal.Visible = True
Me.lblTaxesForStay.Visible = True
Me.lblSubtotalBillingAmount.Visible = True
Me.lblPOPtotal.Visible = True
Me.lbltaxesPOP.Visible = True
Me.lblBillingPOP.Visible = True
/J-Man\
|
|
|
|
|
hi
pls
can u tell me?
i want to enter data to two dimensional array(string)
but it appear err.
this err is " Object reference not set to an instance of an object"
code is
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Private Structure CUSTOM_EXPORT
Dim Name_Renamed As String
Dim ViewName As String
Dim List() As String
Dim filter_Renamed() As String
Dim ColHeadName() As String
Dim ColWidth() As Object
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Dim udtCustom() As CUSTOM_EXPORT
Dim strCol As Object
Dim i As Short
Dim j As Short
i = 0
Do While r.AtEndOfStream <> True
ReadStr = r.ReadLine
If VB.Left(ReadStr, 8)<>"[Export]"And Len(ReadStr)>0 Then
i = i + 1
End If
Loop
For j = 0 To UBound(strCol)
udtCustom(i).List(j) = strCol(j)
udtCustom(i).ColHeadName(j) = varColHeadName(j)
udtCustom(i).ColWidth(j) = varColWidth(j)
Next
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Err is appeared this line " udtCustom(i).List(j) = strCol(j)"
strcol(j) is "Area Code"
it cannot assign this value
appear err.
thz for all
|
|
|
|
|
This is VB6 ? I'd say that List() needs to be allocated to be an array, it's probably null.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|