Hi there I am creating a system where I link a .net app to a oracle db and am currently working on linking it to the database so that I can add new users for oracle here is my code:
Imports system.Data.OracleClient Public Class Form1 Dim OracleConn As New OracleConnection 'Declares the name of the connection Dim Command1 As String = "Create user " & txtUsername.text & " default tablespace users defined by password" Dim Create As New OracleCommand(Command1, OracleConn) Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTest.Click Try 'Attempts to connect to oracle OracleConn.ConnectionString = "Data Source=******;User ID=******;Password=******;Unicode=True" 'Defines connection string OracleConn.Open() 'command for opening connection Create.ExecuteNonQuery() 'Executes the Add Command OracleConn.Close() 'Command for closing connection MessageBox.Show("User Added") 'Displays messagebox if above commands work without problems Catch ex As Exception 'If commands under "try" do not work then message appears MsgBox("Error Occurred:" & ex.Message) End Try End Sub End Class
I've edited the connection strings and stuff for security reasons as I'm a paranoid android lol.
Anyways the main problem is when declaring the command named "command1" the system runs into some sort of problem
I've tried not having hte text box addition and having hte button click simply create a user (where I filled in the string as create user john..." etc etc and the user was created.
The main problem is something to do with putting the textbox value inbetween the string and I have no idea why it isn't working. I have tried replacing & with + etc but it does not help. The project shows no errors until I run it and then I get a window with:
"An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object."
then a prompt for tooltips online etc. Which dont seem to help at all.
Can someone tell me what I've done wrong have I forgot to put something in or am I going about this the wrong way?
Thanks for your help.