Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

need help with VB program

Original Message
Name: constantin
Date: February 8, 2008 at 08:58:23 Pacific
Subject: need help with VB program
OS: windows
CPU/Ram: intel
Model/Manufacturer: IBM
Comment:
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 Form1

Private 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 Try

Dim 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.Text

Try
' 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 Exception

Console.WriteLine(ex.Message)

Finally

' Dispose OracleCommand object
cmd.Dispose()

' Close and Dispose OracleConnection object
con.Close()
con.Dispose()

End Try
End Sub

Private 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.CheckedChanged

End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

End 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 If

If ComboBox1.Text = "" Then
MessageBox.Show("ComboBox1 is empty")
End If

If TextBox2.Text = "" Then
MessageBox.Show("username is empty")
End If

If TextBox1.Text <> "rab" Then
MsgBox("error")
Else

If 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 Exception

Console.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.TextChanged

End 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 Form2 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
' Create the connection object

Dim 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.Load

Dim connectstr As String
connectstr = "Data Source=" & TextBox1.Text & ";" & "User ID=" & TextBox1.Text & "Unicode=True; Password=" & TextBox3.Text

Dim myForm As New Form1
myForm.Show()
End Sub

Private 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 Sub

Private 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



Report Offensive Message For Removal


Response Number 1
Name: StuartS
Date: February 8, 2008 at 09:51:18 Pacific
Subject: need help with VB program
Reply: (edit)
So whats the problem?

Stuart


Report Offensive Follow Up For Removal

Response Number 2
Name: constantin
Date: February 9, 2008 at 18:13:10 Pacific
Subject: need help with VB program
Reply: (edit)
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 Form1

Private 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 Try

Dim 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.Text

Try
' 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 Exception

Console.WriteLine(ex.Message)

Finally

' Dispose OracleCommand object
cmd.Dispose()

' Close and Dispose OracleConnection object
con.Close()
con.Dispose()

End Try
End Sub

Private 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.CheckedChanged

End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

End 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 If

If ComboBox1.Text = "" Then
MessageBox.Show("ComboBox1 is empty")
End If

If TextBox2.Text = "" Then
MessageBox.Show("username is empty")
End If

If TextBox1.Text <> "dprod" Then
MsgBox("Datasource is empty")
Else

If 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 Exception

Console.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.TextChanged

End 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.Load

Dim connectstr As String
connectstr = "Data Source=" & TextBox1.Text & ";" & "User ID=" & TextBox1.Text & "Unicode=True; Password=" & TextBox3.Text

Dim myForm As New Form1
myForm.Show()
End Sub

Private 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 Sub

Private 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


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: need help with VB program

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12

help mandriva install last straw!

Icon Scaling in Explorer Bar


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC