Connect to Oracle 10g - vb.net

I finished my project with MSSQL 2008r2 database And vb.net
My company have oracel ERP System (oracle10g+ora6i form)
And I need to move same data from my project. To the company's system
I use
System.Data.SqlClient
library
i need way to connect my Project to erp db

You can use the connection string
string oracle_conn= "Data Source=(DESCRIPTION =(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST = server_Ip_oracle)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = database_name)));User ID=User/Schema;Password=password;Unicode=True";
and then use the code like
using (OracleConnection objConn = new OracleConnection(oracle_conn))
{
Your code here
}

Related

Create Calculated tables in SSAS Tabular Model using Tabular Object Model Program Scripts

I am trying to create an SSAS Tabular database dynamically using the Tabular Object Model (TOM) C# scripts. I am able to create all the components of the tabular Model except for calculated tables and I am unable to find any solutions online.
Any insight on the same is highly appreciated.
Thanks
This can be done through executing a TMSL command that is the DDL for the calculated table using an OLE DB connection with the MSOLAP provider. First the command will need to be executed to create the calculated table. Next the table will need to be processed for it to be available for use, which is covered in the second part of the example below. The same connection string can be used for the both OLE DB and SSAS connection. Make sure properly escape any \ or " in the TMSL command, as well as set the Extended Properties and Provider properties accordingly in the connection string.
string connString = "Data Source=YourSSASInstance;Initial Catalog=YourTabularDatabase;Provider=MSOLAP.7;Integrated Security=SSPI;Extended Properties=Format=Tabular;";
using (OleDbConnection oleDBConn = new OleDbConnection(connString))
{
OleDbCommand oleDBCmd = new OleDbCommand(commandWithTMSL);
oleDBCmd.Connection = oleDBConn;
oleDBConn.Open();
oleDBCmd.ExecuteNonQuery();
}
using (Microsoft.AnalysisServices.Tabular.Server serv = new Microsoft.AnalysisServices.Tabular.Server())
{
serv.Connect(connString);
Microsoft.AnalysisServices.Tabular.Database db = serv.Databases["YourTabularDatabase"];
Model m = db.Model;
m.Tables["NewCalculatedTable"].RequestRefresh(RefreshType.Full);
m.SaveChanges();
}

oracle connection string not working

On a different oracle 11g server, this variant of connection string format works:
Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID))); User Id=myUsername;Password=myPassword;
but when I use this on another oracle 11g server with similar configuration, it doesn't work anymore.
When I use tnsping , the result comes out similar to the connection string above except the service name is blank.
Used EZCONNECT adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=ip address)(PORT=port)))
OK (20 msec)
The DB is also reachable using the SQL Developer. What's wrong with my connection string? I'm working with a web service made in .NET that needs to connect to the oracle DB.
I think you missed out on this part SERVER = DEDICATED
datasource =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = XXXX)(PORT = abc))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = my_orcl_db)

Is it necessary that Data Source of connection string must match the system name

This is my first post to this precious website. I am a new learner of vb.net. I am working on a simple purchase project, where i got some errors. But the first thing is which baffled me is:
This is my connection string at module level, on the developed machine.
Public strCn As String = "Data Source = (local); Initial Catalog = PSys; Integrated Security = false; User ID = sa; Password = 123;"
Is it mandatory that Data Source must be the original name of the System Name. I mean If i use (local) or using ( . ), so will it work or not? Because when i copy my project to any other system for further development so every time i need to change the Data source, otherwise i get the error that: "Network-related or instance-specific error occurred......."
Kindly guide me that what i need to do.
When you are developing an application which uses a database server such as MsSQL it is not wise to install the server along with your application in every pc which is installed to. For example what are you going to do if a customer has a local network with 10 computers? Are you going to install SQL server in all 10 of them? And if so what if they need to share data?
So your best approach (based on common practice by other applications) will be to allow the user to install the SQL server where he wants and let him configure your application and point it to the server's location. If you follow that path then the configuration of your application can be in the setup application or in the application itself.
Now about the development phase, I had a similar situation in which I needed to develop the same application in two different computers. What I did was to install the SQL server in both of them with a named instance "sqlexpress" then in the application I used the
Data.SqlClient.SqlConnectionStringBuilder
class to build the connection string. I did something like this:
Public Function getDevConnectionString() As String
Dim csb As New Data.SqlClient.SqlConnectionStringBuilder(My.Settings.dbConnectionString) '<-My original cs in app settings
csb.DataSource = My.Computer.Name & "\sqlexpress"
Return csb.ConnectionString
End Function
Whenever I need a connection string I simply call getDevConnectionString() which returns the connection string based on the computer name plus the sql server instance name. For example:
Dim cs As String
#If DEBUG Then
cs = getDevConnectionString()
#Else
cs = getReleaseConnectionString()
#End If
where getReleaseConnectionString() is the function that returns your connection string configured by the customer.
Hope this point you the right direction...

SQL Server 2008 Instance connection issue

My problem is the following:
I installes SQL Server 2008 R2 on my Windows Server 2008. I tried it by using default instance name (MSSQLSERVER) and named instance. The Installation was successful without an error. The problem is now:
When I try to connect to my SQL Server with the Management Studio it can't connect to this instance when I write "SERVER1\MSSQLSERVER" as serveraddress. When I write "SERVER1" only in the serveradress field it works.
Note: I always try to connect as SA. The password is right. Dont know if that matters...
But I have to be able to connect to "SERVER1\MSSQLSERVER" because I always get errors when I want to connect to a server without instance by C#.
Can someone tell me where I am mistaking?
EDIT:
The C# code looks like this:
sqlConnection = "data source=(local);persist security info=True;User ID=sa;Password=12345;initial catalog=BBKat"
SqlConnection sqlCon = new SqlConnection( sqlConnection );
SqlCommand sqlCmd = new SqlCommand( sqlCmdString, sqlCon );
I think you are not mistaken at all. You do not write the default instance name while connecting. You can create aliases though as mentioned above.
Try with a single (local) in the server name. and the same in C# web config connectionString as Data Source=(local);Initial Catalog=YOUR_DB;Integrated Security=True
EDIT
Change the connection string as:
data source=(local);Integrated Security=False;User ID=sa;Password=12345;initial catalog=BBKat

Connecting to MS SQL Server from OSX using ActualODBC

I'm developing a cross platform (windows + OSX) application that will be used commercially. The application will need to be able to access a database (MS SQL) and show the data.
I have installed the ActualODBC trial and use the following code to connect to the server:
QString connectionTemplate = "DRIVER={Actual SQL SERVER};SERVER=%1;DATABASE=%2;";
QString connectionString = connectionTemplate.arg("192.168.1.5").arg("Clients");
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName( connectionString );
db.setUserName( "sa" );
db.setPassword( "password" );
if( db.open() )
{
QMessageBox::about( this, tr("Connection"), tr("Connected :)") );
}
however I get the error QODBC3: Unable to connect.
Any ideas what's wrong?
Turns out this was just some settings that I needed to change with the Actual SQL Server drivers!