java - Connecto to SQL Server with c# and JDBC -


i have program in java connect sql server

server = "zf-sql-mtrazdb.nis.local" dbname = "mraz" namebasedatos = "cd_lo" table = "dbo.cd_lo_data" user = "user" password = "pass" url = "jdbc:sqlserver//"+ server + "\\" + dbname + "jdatabasename=" +     namebasedatos driver = "com.microsoft.sqlserver.jdbc_sqlserverdriver" 

now have same visual c# 2010 in windows xp

how can program?? because in java use jdbc, should use jdbc?

thanks all!

the connectionstring similar ole db connection string, not identical. unlike ole db or ado, connection string returned same user-set connectionstring, minus security information if persist security info value set false (default). .net framework data provider sql server not persist or return password in connection string unless set persist security info true.

you can use connectionstring property connect database. following example illustrates typical connection string.

"persist security info=false;integrated security=true;initial catalog=northwind;server=(local)" 

use new sqlconnectionstringbuilder construct valid connection strings @ run time.

private static void opensqlconnection() {     string connectionstring = getconnectionstring();      using (sqlconnection connection = new sqlconnection())     {         connection.connectionstring = connectionstring;          connection.open();          console.writeline("state: {0}", connection.state);         console.writeline("connectionstring: {0}",             connection.connectionstring);     } }  static private string getconnectionstring() {     // avoid storing connection string in code,       // can retrieve configuration file.      return "data source=mssql1;initial catalog=adventureworks;"         + "integrated security=true;"; } 
  1. data source or server oraddressoraddrornetwork address : name or network address of instance of sql server connect. port number can specified after server name : server=tcp:servername, portnumber`
  2. the initial catalog or database : name of database. database name can 128 characters or less.
  3. the integrated security or trusted_connection : when false, user id , password specified in connection. when true, current windows account credentials used authentication. recognized values true, false, yes, no, , sspi (strongly recommended), equivalent true. if user id , password specified , integrated security set true, user id , password ignored , integrated security used.

and other items

i hope :) .


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -