Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Here is a sample of the whole process; we can use three forms to guide through:
On Form 1, 1)You input client options (ODBC which is Radiobutton1 or Native which is Radiobutton2), 2)data source which is TextBox1 such as dprod, user name which is TextBox2, password which is TextBox3(should be encrypted on the screen)and also a next button on same form which is Button1
After next button is clicked, you will need to check if each box is empty or not; If not, you will need to prompt error message for user.
If all the nessary fields filled, you will need to try to connect to database; if the connection fails, prompt for database connection error and detail database feedback error message.
If database connects, close form 1 and open form 2, On form2 , you have owner, table/view selection criteria;
select all the owners out from the database meta table to populate the owner list for the second form by using the opened connection from form 1.
a user picks a lists of owners and possiblely to extend to owners and tables/views,
if owners/table/view selection is null when next is clicked, prompt error message;
if not , you move to the third forms (close the second form) to show ready to Proceed or Cancel ; if Cancel is clicked, exit your program; or
when Proceed is clicked,
constructure SELECTs to read from database metadata,
insert into META* tables
when all the Selects finsihed, prompt the end of process.
thanks,this is my code so far for form1,2 when I ran the program I got you select ODBC and then error even though I put the right username and password:
Imports System
Imports System.Data ' VB.NET
Imports Oracle.DataAccess.Client ' ODP.NET Oracle data provider
Public Class Form1Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create the connection object
Dim con As OracleConnection = New OracleConnection()' Specify the connect string
' NOTE: Modify User Id, Password, Data Source as per your database set up
con.ConnectionString = "User Id=rab;Password=pass;Data Source=dprod"Try
' Open database connection through ODP.NET
con.Open()
Console.WriteLine("Connection to Oracle database established successfully !")
Console.WriteLine(" ")Catch ex As Exception
Console.WriteLine(ex.Message)
End TryDim cmdQuery As String = "SELECT table_name FROM user_tables WHERE table_name like 'META_%"
' Create the OracleCommand object
Dim cmd As OracleCommand = New OracleCommand(cmdQuery)
cmd.Connection = con
cmd.CommandType = CommandType.TextTry
' Fetch data into an OracleDataReader object and display the data on the console. Then, close the connection object
Dim reader As OracleDataReader = cmd.ExecuteReader()
While (reader.Read())' Output PACKAGEGUID and PKG_COMMENT
Console.WriteLine("PACKAGEGUID: " & _
reader.GetDecimal(0) & _
" , " & _
"PKG_COMMENT: " & _
reader.GetString(1))End While
Catch ex As ExceptionConsole.WriteLine(ex.Message)
Finally
' Dispose OracleCommand object
cmd.Dispose()' Close and Dispose OracleConnection object
con.Close()
con.Dispose()End Try
End SubPrivate Sub BindingNavigatorPositionItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChangedEnd Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChangedEnd Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If RadioButton2.Checked = True Then
MsgBox("You chose Native/Direct Connection")
Else
MsgBox("You chose ODBC")
End IfIf ComboBox1.Text = "" Then
MessageBox.Show("ComboBox1 is empty")
End IfIf TextBox2.Text = "" Then
MessageBox.Show("username is empty")
End IfIf TextBox1.Text <> "rab" Then
MsgBox("error")
ElseIf TextBox2.Text <> "pass" Then
MsgBox("password is not right")
Else
Me.Hide()
Form2.Show()
End If
End If' 1)Create the connection object
Dim con As OracleConnection = New OracleConnection()
'2) Open database connection through ODP.NET
Try' Open the connection
con.Open()
Console.WriteLine("Connection to Oracle database established successfully !")
Console.WriteLine(" ")Catch ex As Exception
Console.WriteLine(ex.Message)
End Try'3)Create command object to perform a query against the database
Dim cmdQuery As String = "SELECT PACKAGEGUID, PKG_COMMENT FROM META_AUDIT"
' Create the OracleCommand object
Dim cmd As OracleCommand = New OracleCommand(cmdQuery)
cmd.Connection = con
cmd.CommandType = CommandType.Text
'4)Fetch data into an OracleDataReader object and display the data on the console
' Then, close the connection object
Try' Execute command, create OracleDataReader object
Dim reader As OracleDataReader = cmd.ExecuteReader()
While (reader.Read())' Output Employee Name and Number
Console.WriteLine("PACKAGEGUID : " & _
reader.GetDecimal(0) & _
" , " & _
"PKG_COMMENT : " & _
reader.GetString(1))End While
Catch ex As ExceptionConsole.WriteLine(ex.Message)
Finally
' Dispose OracleCommand object
cmd.Dispose()' Close and Dispose OracleConnection object
con.Close()
con.Dispose()End Try
' Specify the connect string
' NOTE: Modify User Id, Password, Data Source as per your database set up
'con.ConnectionString = "User Id=rab;Password=pass;Data Source=dprod;"
Dim myForm As New Form2
myForm.Show()
'Me.Hide()
'Form2.Show()End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChangedEnd Sub
Private Sub TextBox3_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChangedEnd Sub
Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
End Class
,,,,,,,,,,,,,,,,,,,,this is Form2 below
Imports System.Data.OracleClientPublic Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create the connection objectDim con As OracleConnection = New OracleConnection()
con.ConnectionString = "Data Source=dprod;User ID= rab; Unicode=True; Password=pass"End Sub
Private Sub Buton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadDim connectstr As String
connectstr = "Data Source=" & TextBox1.Text & ";" & "User ID=" & TextBox1.Text & "Unicode=True; Password=" & TextBox3.TextDim myForm As New Form1
myForm.Show()
End SubPrivate Sub Buton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myForm As New Form1
myForm.Show()
'Me.Hide()
'Form1.Show()
End SubPrivate Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
End Sub
End Class

Hi Stuart there are few problems:1)when I login I put the wrong username and ran the prog.it willn't tell me username isn't right,also when I put wrong Datasource like dpeep it tells me Datasource empty,it should say wrong Datasource.Even If all the nessary fields filled, I can't connect to database(isn't giving me connection fails, prompt for database connection error and detail database feedback error message).I want If database connects, close form 1 and open form 2(it opens Form2 even if some information is wrong).There are some more problems but I hope u could help me with these first,thanks alot this is updated version of the code:
Imports System
Imports System.Data ' VB.NET
Imports Oracle.DataAccess.Client ' ODP.NET Oracle data provider
Public Class Form1Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create the connection object
Dim con As OracleConnection = New OracleConnection()' Specify the connect string
' NOTE: Modify User Id, password, Data Source as per your database set up
con.ConnectionString = "User Id=smughrabi;password=Sul9966;Data Source=dprod"Try
' Open database connection through ODP.NET
con.Open()
Console.WriteLine("Connection to Oracle database established successfully !")
Console.WriteLine(" ")Catch ex As Exception
Console.WriteLine(ex.Message)
End TryDim cmdQuery As String = "SELECT table_name FROM user_tables WHERE table_name like 'META_%"
' Create the OracleCommand object
Dim cmd As OracleCommand = New OracleCommand(cmdQuery)
cmd.Connection = con
cmd.CommandType = CommandType.TextTry
' Fetch data into an OracleDataReader object and display the data on the console. Then, close the connection object
Dim reader As OracleDataReader = cmd.ExecuteReader()
While (reader.Read())' Output PACKAGEGUID and PKG_COMMENT
Console.WriteLine("PACKAGEGUID: " & _
reader.GetDecimal(0) & _
" , " & _
"PKG_COMMENT: " & _
reader.GetString(1))End While
Catch ex As ExceptionConsole.WriteLine(ex.Message)
Finally
' Dispose OracleCommand object
cmd.Dispose()' Close and Dispose OracleConnection object
con.Close()
con.Dispose()End Try
End SubPrivate Sub BindingNavigatorPositionItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChangedEnd Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChangedEnd Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If RadioButton2.Checked = True Then
MsgBox("You chose Native/Direct Connection")
Else
MsgBox("You chose ODBC")
End IfIf ComboBox1.Text = "" Then
MessageBox.Show("ComboBox1 is empty")
End IfIf TextBox2.Text = "" Then
MessageBox.Show("username is empty")
End IfIf TextBox1.Text <> "dprod" Then
MsgBox("Datasource is empty")
ElseIf TextBox2.Text <> "smughrabi" Then
MsgBox("username is not right")
Else
Me.Hide()
Form2.Show()
End If
End If' 1)Create the connection object
Dim con As OracleConnection = New OracleConnection()
'2) Open database connection through ODP.NET
Try' Open the connection
con.Open()
Console.WriteLine("Connection to Oracle database established successfully !")
Console.WriteLine(" ")Catch ex As Exception
Console.WriteLine(ex.Message)
End Try'3)Create command object to perform a query against the database
Dim cmdQuery As String = "SELECT PACKAGEGUID, PKG_COMMENT FROM META_AUDIT"
' Create the OracleCommand object
Dim cmd As OracleCommand = New OracleCommand(cmdQuery)
cmd.Connection = con
cmd.CommandType = CommandType.Text
'4)Fetch data into an OracleDataReader object and display the data on the console
' Then, close the connection object
Try' Execute command, create OracleDataReader object
Dim reader As OracleDataReader = cmd.ExecuteReader()
While (reader.Read())' Output Employee Name and Number
Console.WriteLine("PACKAGEGUID : " & _
reader.GetDecimal(0) & _
" , " & _
"PKG_COMMENT : " & _
reader.GetString(1))End While
Catch ex As ExceptionConsole.WriteLine(ex.Message)
Finally
' Dispose OracleCommand object
cmd.Dispose()' Close and Dispose OracleConnection object
con.Close()
con.Dispose()End Try
' Specify the connect string
' NOTE: Modify User Id, password, Data Source as per your database set up
'con.ConnectionString = "User Id=smughrabi;password=password;Data Source=dprod;"
Dim myForm As New Form2
myForm.Show()
'Me.Hide()
'Form2.Show()End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChangedEnd Sub
Private Sub TextBox3_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
End Sub
Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
End Class
,,,,,,,,,,,,,,,,,,,this is Form 2 below:Imports System.Data.OracleClient
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cn As New OracleConnection
cn.ConnectionString = "Data Source=dprod;User ID=smughrabi; Unicode=True; Password=Sul9966"End Sub
Private Sub Buton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadDim connectstr As String
connectstr = "Data Source=" & TextBox1.Text & ";" & "User ID=" & TextBox1.Text & "Unicode=True; Password=" & TextBox3.TextDim myForm As New Form1
myForm.Show()
End SubPrivate Sub Buton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myForm As New Form1
myForm.Show()
'Me.Hide()
'Form1.Show()
End SubPrivate Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
End Sub
End Class

![]() |
concatenate variable to s...
|
Using a proxy through a w...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |