0

I have a problem with share a C# program on network.

I installed SQL Server 2008 R2 and I enabled TCP/IP and remote connection on it also I can connect to server with sqlcmd -U usr -P pwd -S 192.168.1.11\SQLEXPRESS without any problem but when I change connection string like this:

192.168.1.11\SQLEXPRESS;initial catalog=HouseTrade;User ID=usr;Password=pwd; 

The program can't connect to database.

Do you have any idea for share this program in the network?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
amin
  • 9
  • 2

2 Answers2

0

If you are asking how to call the SQLCMD with a Catalog name in it

sqlcmd -U usr -P pwd -d HouseTrade -S 192.168.1.11\SQLEXPRESS

If that is not what you are asking please edit you question to make it clear

sqlcmd 
   -a packet_size
   -A (dedicated administrator connection)
   -b (terminate batch job if there is an error)
   -c batch_terminator
   -C (trust the server certificate)
   -d db_name
   -e (echo input)
   -E (use trusted connection)
   -f codepage | i:codepage[,o:codepage] | o:codepage[,i:codepage]
   -h rows_per_header
   -H workstation_name
   -i input_file
   -I (enable quoted identifiers)
   -k[1 | 2] (remove or replace control characters)
   -K application_intent
   -l login_timeout
   -L[c] (list servers, optional clean output)
   -m error_level
   -M multisubnet_failover
   -N (encrypt connection)
   -o output_file
   -p[1] (print statistics, optional colon format)
   -P password
   -q "cmdline query"
   -Q "cmdline query" (and exit)
   -r[0 | 1] (msgs to stderr)
   -R (use client regional settings)
   -s col_separator
   -S [protocol:]server[\instance_name][,port]
   -t query_timeout
   -u (unicode output file)
   -U login_id
   -v var = "value"
   -V error_severity_level
   -w column_width
   -W (remove trailing spaces)
   -x (disable variable substitution)
   -X[1] (disable commands, startup script, environment variables and optional exit)
   -y variable_length_type_display_width
   -Y fixed_length_type_display_width
   -z new_password 
   -Z new_password (and exit)

   -? (usage)

More details can be found here http://technet.microsoft.com/en-us/library/ms162773.aspx

Mauricio Gracia Gutierrez
  • 10,288
  • 6
  • 68
  • 99
0

I found a solution. We can add guest user and get enough permission to it after that we can use this connection string:

data source=ip\SQLEXPRESS;initial catalog=HouseTrade;integrated security=true;
chue x
  • 18,573
  • 7
  • 56
  • 70
amin
  • 9
  • 2