|
yeh really not sure where to head for this one, perhaps do some research and experimentation, my idea has no actual stuff to back it up so your on your own unless someone else can help.
|
|
|
|
|
I am trying to connect to oracle database with the following code in VB.net 2003, but i am not getting anything coming back and dont know what is happening as the catch is not showing any errors the program just keeps running. I have this code behind a button should this code be in form view or elsewhere.
Imports System<br />
Imports System.Data<br />
Imports Oracle.DataAccess.Client<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
<br />
<br />
''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br />
' Create the connection object<br />
Dim con As OracleConnection = New OracleConnection<br />
<br />
' Specify the connect string<br />
' NOTE: Modify User Id, Password, Data Source as per your database set up<br />
<br />
<br />
con.ConnectionString = "User Id=user_id;Password=user_pword;Data Source=ora9idb;"<br />
<br />
<br />
'''''''''''''''''''''''''''''''''''''''''''''''''''''''<br />
Try<br />
' Open the connection through ODP.Net<br />
con.Open()<br />
Console.WriteLine("Connection to Oracle database established successfully !")<br />
Console.WriteLine(" ")<br />
<br />
<br />
Catch ex As Exception<br />
<br />
Console.WriteLine(ex.Message)<br />
'txtStatus.Text &= ex.ToString<br />
End Try<br />
''''''''''''''''''''''''''''''''''''''''''''''''<br />
'Create command object to perform a query against the database<br />
Dim cmdQuery As String = "SELECT empno, ename FROM emptab"<br />
<br />
' Create the OracleCommand object<br />
Dim cmd As OracleCommand = New OracleCommand(cmdQuery)<br />
cmd.Connection = con<br />
cmd.CommandType = CommandType.Text<br />
<br />
<br />
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br />
'Fetch data into an OracleDataReader object and <br />
'display the data on the console. Then, close the connection object<br />
<br />
Try<br />
<br />
<br />
<br />
' Execute command, create OracleDataReader object<br />
Dim reader As OracleDataReader = cmd.ExecuteReader()<br />
While (reader.Read())<br />
<br />
' Output Employee Name and Number<br />
Console.WriteLine("Employee Number : " & _<br />
reader.GetDecimal(0) & _<br />
" , " & _<br />
"Employee Name : " & _<br />
reader.GetString(1))<br />
<br />
End While<br />
Catch ex As Exception<br />
<br />
Console.WriteLine(ex.Message)<br />
<br />
Finally<br />
<br />
' Dispose OracleCommand object<br />
cmd.Dispose()<br />
<br />
' Close and Dispose OracleConnection object<br />
con.Close()<br />
con.Dispose()<br />
<br />
End Try<br />
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<br />
<br />
End Sub
|
|
|
|
|
Which Oracle client is installed on the workstation?
Which Oracle library are you using in your code??
I'm assuming ora9idb is the name of your database, NOT the server on which it resides. Is ora9idb defined in your tnsnames.ora file??
I don't use Oracle at all, so my ability to support this is quite limited.
|
|
|
|
|
Thanks for helping Dave.
Installed 9i, yes i just changed the code, The problems been sorted now as i can use access instead what a relief as done some last year in VB.net 2003.
I have got the code in VB.Net 2003 but must run it in 2005 VB. What will i require to be able to change the code for this. What is best way? I understand that once you run in 2005 you cannot go back and you cannot edit it 2005, so How do i change the code so it does not have any errors before i run in 2005.
This is more your speciality then.
Oracle is long gone.
|
|
|
|
|
kendo17 wrote: I have got the code in VB.Net 2003 but must run it in 2005 VB. What will i require to be able to change the code for this.
Open the project in VS2005 and it'll get converted automatically. There might be some breaking changes, but the Upgrade Wizard will tell you about more of those.
kendo17 wrote: I understand that once you run in 2005 you cannot go back
True. Once the project is opened up and converted in 2005, you can no longer open it in 2003. But what's stopping you from just making a copy of the project and keeping one copy for each version?
kendo17 wrote: and you cannot edit it 2005
Don't you mean 2003?? You can edit all you want, just don't depend on Intellisense to tell you what's right and wrong. You just can't compile a 2005 project under 2003.
How do you change the code so it opens in 2005 without errors? You don't! You open the project, let it upgrade, then fix whatever breaks.
|
|
|
|
|
When I run this code, only one DDL (cboSDB) populates, the other remains empty. Code does not trip any errors. Am I missing something obvious? Thanks
******************
Using conn As New SqlConnection(connect)
Try
conn.Open()
' get DataTable with all available metadata collections
Dim dt1 As DataTable = conn.GetSchema()
Dim cmd As SqlCommand = New SqlCommand
Dim dr As SqlDataReader
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "sp_databases"
cmd.Connection = conn
dr = cmd.ExecuteReader
cboSDB.Items.Clear()
cboSDB.Items.Add(New ListItem("Select", "0"))
cboDDB.Items.Clear()
cboDDB.Items.Add(New ListItem("Select", "0"))
' bind DataTable controls to display rows
cboSDB.DataSource = dr
cboSDB.DataTextField = "DATABASE_NAME"
cboSDB.DataValueField = "DATABASE_NAME"
cboSDB.DataBind()
' This is where it won't work yet code is exactly the same as above.
cboDDB.DataSource = dr
cboDDB.DataTextField = "DATABASE_NAME"
cboDDB.DataValueField = "DATABASE_NAME"
cboDDB.DataBind()
' End
cmdSConn.Enabled = False
Catch ex As System.Exception
clsE.logWizError(ex.Message.ToString, "COULD NOT CONNECT TO SOURCE.", sClient)
lblMsg.Text = "COULD NOT CONNECT TO DATABASE. PLEASE TRY AGAIN."
lblMsg.ForeColor = Drawing.Color.DarkRed
lblMsg.Visible = True
Finally
conn.Close()
End Try
End Using
|
|
|
|
|
You don't do databinding like this using a DataReader. A DataReader reads through the returned records forward only. Since during the first bind, you had the reader go through all the records once, there's no way to get it to go back and do it again for the second bind.
Drop the DataReader and use a DataAdapter to fill a DataTable, then you can bind both ComboBox's (please don't use abbreviations like DDL!) to that DataTable.
|
|
|
|
|
select convert(varchar(2),datepart(dd,travel_date))from booking_details
this returns me :…….
15
21
24
8
5
But in this o/p I want 08 instead of 8 please suggest
|
|
|
|
|
This is the wrong forum for this question, but one answer might be:
select right('0'+convert(varchar(2),datepart(dd,travel_date)),2) from booking_details
Hope that helps.
Ben
|
|
|
|
|
Dear Ben
Thanks for your help.
It's working now.
|
|
|
|
|
|
This has nothing to do with VB or VB.NET. Ask this question in the SQL forum.
|
|
|
|
|
I want to add a control button to an existing command bar.
Dim CmdBar As CommandBar
Dim Cntrl As CommandBarControl
Cntrl = CmdBar.Controls.Add(MsoControlType.msoControlButton,Before:=1)
cntrl.Caption = "Test"
cntrl.DescriptionText = "Test Button"
Cntrl.TooltipText = "Test"
Cntrl.Tag = "TEST"
Cntrl.BeginGroup = True
Cntrl.Visible = True
Commandbar can be of 3 types
Enum MsoBarType
msoBarTypeNormal = 0 ' toolbar
msoBarTypeMenuBar = 1 ' menu bar
msoBarTypePopup = 2 ' menu, submenu or
' shortcut menu
End Enum
Problem is that if the type of the Commandbar is msoBarTypePopup then only i am able to see the added button in the Commandbar and if it is of type msoBarTypeNormal then i cant see it while controls count is increased by 1.
I am working on Powerpoint and various commandbars provided are "Shapes" "Formatting" "Thumbnails" etc.
When i right click on any slide "Formatting" command bar opens,to which i want to add a control button. "Formatting" commandbar is of type msoBarTypeNormal. Does anybody have an idea how i can achieve this
|
|
|
|
|
In my vb .net app I would like to display a pdf file after they clicked the file name out of the listbox. I got this already working with webbrowser control.
vGeselecteerdeAfbeelding = Me.ListBox1.SelectedItem<br />
Me.WebBrowser1.Navigate(vAfbeeldingPadTemp & vGeselecteerdeAfbeelding & ".pdf")
During the pdf file is displayed I want to let the user rename the file, but the webbrowser keeps the PDF file open. Is there a way to close this?
I tried to kill the acrobat.exe proces, but it's very slow.
|
|
|
|
|
what happens if you just navigate to a blank page or something? (does that close the pdf file??)
otherwise there is a control 'Adobe pdf reader' in the com components that will probably give you more control over the pdf file (you will have to have adobe reader installed for the development)
(the control can be added to the toolbox by rightclicking in the toolbox and click 'choose items...' then go to 'com components' tab and there you'll find the control)
hope this helps
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistakes.
|
|
|
|
|
When I navigate to another PDF, the earlier opened PDF is still opened.
Your other suggestion worked well!
File.Copy("C:\1.pdf", "C:\" & Me.TextBox1.Text & ".pdf")<br />
Me.AxAcroPDF1.src = ""<br />
File.Delete("C:\1.pdf")
Thanks
|
|
|
|
|
Hi everyone,
Can anyone help me? How can I send an e-mail from a WINDOWS XP PC without using OUTLOOK EXPRESS like applications. I need help using Visual Basic 6.0.
Pls help me.
monSur
|
|
|
|
|
|
Hi all,
I have written one function to store the error in the database.The function codes are
[code]
Public Function PopulateFileDetails(ByVal JobCode As String, ByVal ChapterID As String, ByVal nStage As Integer) As String
Try
Catch ex As Exception
CaptureError("Populate Values ", "Name", ex)
End Try
End Function
[/code]
This function will get the arguments as
1.The Function name which generates the error
2.Username
3.The message ...(Ex as exception).
Now the problem is that i am forcing the user to give the
the function name which generated the error. Is there any other method where i can pass the name which caused the error. In this case it is PopulateFileDetails....
Thanks in Advance
Dana
|
|
|
|
|
The exception object has a stack trace which will end with the method that you are in.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillionOneHundredAndFortySevenMillionFourHundredAndEightyThreeThousandSixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it )
|
|
|
|
|
Thanks Graus
That one did the trick
Dana
|
|
|
|
|
hi all
i am working on a project that uses a tab control having three tabs, now i need to add a zoom feature on the form that will allow the tab control to zoom in and zoom out with every control on it as well. if some one has any idea about it then please let me know. thanks in advance.
help everyone
|
|
|
|
|
One way to achieve Zoom effect with TabControl is to increase or decrease size of tab control and all of its pages including its contents according to the Zoom factor which is required.
I tried to implement this functionality with a tab control and following code should give you the desired result-
---------------------Code Start--------------------------------------------------------
Code to ZoomIn-
----------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnZoomIn.Click<br />
<br />
Dim ZoomFactor As Integer = 25 'In percent <br />
<br />
For Each tbpg As TabPage In Me.TabControl1.TabPages<br />
<br />
For Each cntrl As Control In tbpg.Controls<br />
<br />
cntrl.Width += cntrl.Width * ZoomFactor / 100<br />
cntrl.Height += cntrl.Height * ZoomFactor / 100<br />
<br />
cntrl.Left += cntrl.Left * ZoomFactor / 100<br />
cntrl.Top += cntrl.Top * ZoomFactor / 100<br />
<br />
cntrl.Refresh()<br />
<br />
Next<br />
<br />
Next<br />
<br />
Me.TabControl1.Width += Me.TabControl1.Width * ZoomFactor / 100<br />
Me.TabControl1.Height += Me.TabControl1.Height * ZoomFactor / 100<br />
<br />
Me.TabControl1.Refresh()<br />
<br />
End Sub
---------------------------------
Code to ZoomOut –
---------------------------------
<br />
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnZoomOut.Click<br />
<br />
Dim ZoomFactor As Integer = 25 'In percent <br />
<br />
For Each tbpg As TabPage In Me.TabControl1.TabPages<br />
<br />
For Each cntrl As Control In tbpg.Controls<br />
<br />
cntrl.Width -= cntrl.Width * ZoomFactor / 100<br />
cntrl.Height -= cntrl.Height * ZoomFactor / 100<br />
<br />
cntrl.Left -= cntrl.Left * ZoomFactor / 100<br />
cntrl.Top -= cntrl.Top * ZoomFactor / 100<br />
<br />
cntrl.Refresh()<br />
<br />
Next<br />
<br />
Next<br />
<br />
Me.TabControl1.Width -= Me.TabControl1.Width * ZoomFactor / 100<br />
Me.TabControl1.Height -= Me.TabControl1.Height * ZoomFactor / 100<br />
<br />
Me.TabControl1.Refresh()<br />
<br />
End Sub
----------------------Code End---------------------
I hope this helps .
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
thank you verry much for your kind help,
but i need to enlarge the font size of each control and also control the anchoring of each control.
i think the reason behind the unusual behavior of the tab control is that i set the location of the tab control on form's load event.
let me tell you what i did
i take a panel, place the tab control on that panel so that the panel become the parent of the tab control, now i set the auto scroll property of panel to true, set the dock property of panel to fill. this will zoom the tab control, the other control on each tab but the font size remains same. what else i can do to work it properly.
i more thing i have one more tab control on the first tab page of the main tab control. the things goes complicated now with this second tab control.
thanks in advance
help everyone
-- modified at 6:50 Wednesday 24th October, 2007
|
|
|
|
|
Font can be resized using code like this-
cntrl.Font = New Font(cntrl.Font.Name, cntrl.Font.Size + cntrl.Font.Size * ZoomFactor / 100, cntrl.Font.Style, GraphicsUnit.Pixel)
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|