Showing posts with label connecting. Show all posts
Showing posts with label connecting. Show all posts

Friday, March 30, 2012

need help connecting to sql sever

Hi

I am able to connect to an sql server from my server explorer. Can't seem to connect
to an sql server from my code.

this is what i am doing

String strConnection = "server=FRANK;database=Northwind;integrated security=true;";
SqlConnection objConnection = new SqlConnection(strConnection);
objConnection.Open
objConnection.Close();

error Login Failure for user FRANK

I know that my server name is FRANK because thats what it says on my Sql Service manager.

And i use that same server name when i connect from my Server Explorer(using Visual Studio.NET) and then i get a listing of the the Databases that are associated with my SQL Server.

I have no problems coonecting to an Access dataBase using OLedbConnectionI'm not sure if "server" is the same as "Data Source", but try using "Data Source" instead:

String strConnection = "Data Source=FRANK;database=Northwind;integrated security=true";sql

Need help connecting to server with DSN

Hi all,

I am used to connecting to my database using a querystring and a connection like this:


string connectionString = "server=\'myserver\'; user id=\'myuser\'; password=\'mypw;database=\'mydb\'";
System.Data.IDbConnection dbConnection = new System.Data.SqlClient.SqlConnection(connectionString);

I write in C# and don't know how to connect to a database using a DSN. I have this VB code that's supposed to connect with DSN:

<%
set conn = Server.CreateObject("ADODB.Connection")
conn.open"DSN=MyDSN;UID=user;PWD=password;DATABASE=databasename"
%>

But I need it in C#...

I tried using a query string like this one


string connectionString="DSN=mydsn;UID=myuser;PWD=mypw;DATABASE=mydb";

and got this error :Unknown connection option in connection string: dsn. :

Any help would be greatly appreciated... thanksPlease check the following :


OdbcConnection cn;
OdbcCommand cmd;
string MyString;

MyString="Select * from test";

cn= new OdbcConnection("dsn=myDSN;UID=myUid;PWD=myPwd;");
cmd=new OdbcCommand(MyString,cn);
cn.Open();
......

|||that's classic ASP code in VBScript - not ASP.NET code in VB.NET

Anyway, is there a particular reason you NEED to use a DSN? it IS possible, but it's not the best option.

Need help connecting to a SQL 2005 server

Hoi,

Can someone help me? I have made a website with a database. Local on my pc all work fine. but now i need to set it op on my webhost.

all pages with no database access workSmile but the ones with database controls i getSad:

Server Error in '/' Application.

Login failed for user 'username'..

I got from my webhost:

db server:

db name:

db user:

db ww:

How do i setup the connectionstring to workt with this?

I'm totaly new at this so all help is welcome.

Gr.

W.

You can have a look atconnectionstrings.com for an example on how to set up your connection string. Also read your web hosts documentation as they will probably tell you how to do this.

Need help connecting java to mssql, I'm even lost at install

Hello,

Hope anyone in here can help.
I have tried to install the SQL Server 5 Express, but can't seem to get it to work properly.
I got a terrible name set as default for my database, as well as a terrible name for my username.
I can't find a place to change this to something more manageable.

It is further set to windows auth, but trying to set it to both, and trying a username (and password) always gives me a log in error.

I've tried searching all over the net and in here for a simple tutorial, but can't seem to find one that helps me more than it confuses me.

*****
The second part of the problem is that I have a java program which I want to connect to the database and use the tables in it, but I am at loss to how I can find what username (and password) I am supposed to have, what "url" it needs etc.
I have the jdbc driver so that part should work, I can successfully log to other mssql databases (at work/school), but not my own.

Hope you can help, and thanks in advance.

Hi,

to change a database name

alter database testdb

modify name = TestTmpDB

go

and to chagne user name

alter user AbolrousHazem

with Name = TempTestUser

go

while connecting to SQL Server from Java which error you get? you have wrote that you have set it with Windows Authentication, have you cross checked with Connectilon String?

HTH

Hemantgiri S. Goswami

|||

Hi Murky,

I would encourage you to use the SQL Server 2005 JDBC Driver. You can download it from here: http://msdn2.microsoft.com/en-us/data/aa937724.aspx. To connect to SQL Server using the driver, please refer to the section of that page regarding building the Connection String http://msdn2.microsoft.com/en-us/library/ms378428.aspx. Note, connection string and url are synonyms. There are also many sample java applications available at the first link too.

Note that you can connection to SQL Server using two methods:

1. Username and Password Credentials

2. Windows Authentication.

To do a windows authenticated connection, the server should have been setup with "mixed-mode authentication". If you installed with all the default options, this feature was not installed then. If it was not then you need to use your username/password credentials or reconfigure the server to use mixed-mode authentication.

Hope this helps.

Regards,

Jaaved Mohammed

Wednesday, March 28, 2012

Need Help : Connecting Locally

[WinXP Pro SP2, SQL Server 2000 SP4, VS C++ 2005 Express]
A humble hello to all,
I have spent days trying to simply connect to an instance of SQL Server
2000 SP4 from a program written in C++/CLI using VS C++ 2005 Express. I
originally had SQL server 2000 Dev Ed and SQL Server 2005 Express installed
side by side. I could not connect to either server. I uninstalled both SQL
2005 Express and SQL 2000 Dev Ed, then re-installed SQL SVR 2000 Dev Ed and
applied Service Pack 4. Both the SQL Server 2000 instance and my application
are on the same machine (local). The Server Instance is running and I've
enabled the SQL Server Agent, DTC, and OLAP just for good measure. yes, I'm
very new to SQL server and it's various services, etc. and I'm totally lost
and loosing hair. I've included my code and the settings in SQL Enterprise
Manager and Client Network Utility below. If more information is needed, I'l
l
post it. Any help will be greatly appreciated.
TIA,
M
***Code***
(System, System.data, System.XML referenced}
using namespace System;
using namespace System::Data;
using namespace System::Data::SqlClient;
int main(array<System::String ^> ^args)
{
SqlConnection ^ connection = gcnew SqlConnection();
//Windows Integrated Security
connection->ConnectionString =
"Persist Security Info=False;Integrated Security=SSPI;"
"Server= COMP\DEV_SQL;Data Source=(local);"
"Initial Catalog=My_DB;";
{note: tried with and w/o Server clause}
try {
connection->Open();
Console::WriteLine(L"Connected!");
}
catch (SqlException ^ e) {
Console::WriteLine(L"Not Connected : {0}", e->Message);
}
finally {
connection->Close();
Console::WriteLine(L"Connection Closed");
}
return 0;
}
***OUTPUT *** (both Debug and Release Compile)
Not Connected : An error has occurred while establishing a connection to the
server. When connecting to SQL Server 2005, this failure may be caused by
the fact that under the default settings SQL Server does not allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not open a
connection to SQL Server)
Connection Closed
{note: error always says SQL server 2005, not SQL Server 2000}
***SQL Server Enterprise Manager Settings***
General Tab -
ServerName : COMP\DEV_SQL
Prod: SQL Developer Edition
OS : Windows NT - 5.1 (2600) {WinXP Pro running}
Prod Ver: 8.00.2039 (SP4)
Autostart policies when OS starts: SQL Server checked
Startup Parameters:
-e C:\.MSSQL$DEV_SQL\data\master.mdf
-d C:\.MSSQL$DEV_SQL\log\ERRORLOG
-I C:\.MSSQL$DEV_SQL\data\mastlog.ldf
Network Configuration:
Protocols: Named Pipes and TCP/IP enabled
Network Libraries: Named Pipes, TCP/IP, NWLink, VIA(Giganet, Qlogic,
Server Net II)
{all Network Libraries are version 8.00.2039}
Memory Tab -
Dynamically configure SQL memory selected : min 0, max 503MB
Reserve physical memory for SQL Server: Not Checked
Minimum query memory: 1024 KB
{Configured values selected}
Processor Tab -
Processor Control:
Maximum number of worker threads :255
Boost SQL Server priority: Not Checked
Use WinNT Fibers: Not Checked
Parallelism:
Use all available processors: Selected
Minimum query plan threshold : 5
{Configured values selected}
Security Tab -
Authentication: Windows Only
Audit Level: None
Cross-database Ownership Chaining: Not Checked
Startup Service Account : System Account
Connections Tab -
Maximum concurrent user connections: 0 (unlimited)
Default connection options: No Options Checked
Remote Server Connections:
Allow remote servers to connect using RPC: Not Checked
Query time-out: 600 seconds
Enforce distributed transactions (MTS): Not Checked
{Configured values selected}
Server Settings Tab -
Default language: English
Server Behavior :
Allow modifications directly to catalog: Not Checked
Nested Triggers: Checked
Use query governor: Not Checked
SQL Mail Profile: Blank (not setup yet)
2 digit year support: 1950-2049
{Configured values selected}
Database Settings Tab -
Default index fill factor -
Fixed: Not Checked
Backup and Restore -
Timeout period: Wait Indefinitely selected
Default backup media retention: 0 days
Recovery -
Recovery Interval: 0 min
New Database Default Location
Data Directory: Blank (not filled in)
Log Directory: Blank (not filled in)
{Configured values selected}
Replication Tab -
Publishing and distribution : COMP\DEV_SQL is not configured for either
***SQL Server Client Network Utility***
General Tab -
Enabled Protocols: Named Pipes. TCP/IP
Force Protocol Encryption: Not Checked
Enable Shared Memory Protocol: Checked!
Alias Tab -
No Aliases are configured
DB-Library Options Tab -
DB-Library Information: Windows\System32\NTWDBLIB.DLL, version 8.00.2039
Automatic ANSI to OEM conversion: Checked
Use International Settings: Checked
Network Libraries Tab -
Named Pipes, TCP/IP, Multiprotocol, NWLink, VIA (Giganet, Qlogic)
{Note: these libraries are located in System32 directory and are versio
n
8.0.341 while the Enterprise Manager Network Libraries are located in
MSSQL$Dev_2000\binn directory and are version 8.0.2039}
***SQL Server Enterprise Manager Settings***
General Tab -
ServerName : COMP\DEV_SQL
Prod: SQL Developer Edition
OS : Windows NT - 5.1 (2600) {WinXP Pro running}
Prod Ver: 8.00.2039 (SP4)
Autostart policies when OS starts: SQL Server checked
Startup Parameters:
-e C:\.MSSQL$DEV_SQL\data\master.mdf
-d C:\.MSSQL$DEV_SQL\log\ERRORLOG
-I C:\.MSSQL$DEV_SQL\data\mastlog.ldf
Network Configuration:
Protocols: Named Pipes and TCP/IP enabled
Network Libraries: Named Pipes, TCP/IP, NWLink, VIA(Giganet, Qlogic,
Server Net II)
{all Network Libraries are version 8.00.2039}
Memory Tab -
Dynamically configure SQL memory selected : min 0, max 503MB
Reserve physical memory for SQL Server: Not Checked
Minimum query memory: 1024 KB
{Configured values selected}
Processor Tab -
Processor Control:
Maximum number of worker threads :255
Boost SQL Server priority: Not Checked
Use WinNT Fibers: Not Checked
Parallelism:
Use all available processors: Selected
Minimum query plan threshold : 5
{Configured values selected}
Security Tab -
Authentication: Windows Only
Audit Level: None
Cross-database Ownership Chaining: Not Checked
Startup Service Account : System Account
Connections Tab -
Maximum concurrent user connections: 0 (unlimited)
Default connection options: No Options Checked
Remote Server Connections:
Allow remote servers to connect using RPC: Not Checked
Query time-out: 600 seconds
Enforce distributed transactions (MTS): Not Checked
{Configured values selected}
Server Settings Tab -
Default language: English
Server Behavior :
Allow modifications directly to catalog: Not Checked
Nested Triggers: Checked
Use query governor: Not Checked
SQL Mail Profile: Blank (not setup yet)
2 digit year support: 1950-2049
{Configured values selected}
Database Settings Tab -
Default index fill factor -
Fixed: Not Checked
Backup and Restore -
Timeout period: Wait Indefinitely selected
Default backup media retention: 0 days
Recovery -
Recovery Interval: 0 min
New Database Default Location
Data Directory: Blank (not filled in)
Log Directory: Blank (not filled in)
{Configured values selected}
Replication Tab -
Publishing and distribution : COMP\DEV_SQL is not configured for either
***SQL Server Client Network Utility***
General Tab -
Enabled Protocols: Named Pipes. TCP/IP
Force Protocol Encryption: Not Checked
Enable Shared Memory Protocol: Checked!
Alias Tab -
No Aliases are configured
DB-Library Options Tab -
DB-Library Information: Windows\System32\NTWDBLIB.DLL, version 8.00.2039
Automatic ANSI to OEM conversion: Checked
Use International Settings: Checked
Network Libraries Tab -
Named Pipes, TCP/IP, Multiprotocol, NWLink, VIA (Giganet, Qlogic)
{Note: these libraries are located in System32 directory and are versio
n
8.0.341 while the Enterprise Manager Network Libraries are located in
MSSQL$Dev_2000\binn directory and are version 8.0.2039}Micus (NoEmail@.Nowhere.org) writes:
> "Persist Security Info=False;Integrated Security=SSPI;"
> "Server= COMP\DEV_SQL;Data Source=(local);"
> "Initial Catalog=My_DB;";
> {note: tried with and w/o Server clause}
Try removing the Data Source bit. Data Source and Server are the same
thing. But Data Source points to a default instance, and apparently
you SQL 2000 instance is a named instance.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns9802EF6B6F50DYazorman@.127.0.0.1...
> Micus (NoEmail@.Nowhere.org) writes:
> Try removing the Data Source bit. Data Source and Server are the same
> thing. But Data Source points to a default instance, and apparently
> you SQL 2000 instance is a named instance.
Erland,
I removed the Data Source clause and received the same error message.
Anything else you can think of to try, I'll plug it in and run it.
Thank you,
- M

> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx|||Micus (no@.way) writes:
> "Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
> news:Xns9802EF6B6F50DYazorman@.127.0.0.1...
> Erland,
> I removed the Data Source clause and received the same error message.
> Anything else you can think of to try, I'll plug it in and run it.
When I think of it, don't you need to double the \ in the string? It also
looks funny that there are no concatenation operators, but it may be this
CLI thing you mentioned, that I don't know what it is.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns98036703E5193Yazorman@.127.0.0.1...
> Micus (no@.way) writes:
[vbcol=seagreen]
> When I think of it, don't you need to double the \ in the string? It also
> looks funny that there are no concatenation operators, but it may be this
> CLI thing you mentioned, that I don't know what it is.
>
I'm embarrassed... I got so wound up in installing SQL Server(both 2005
Express and 2000) and playing with the Server Explorer (VS.NET 2003), that I
didn't even notice a very basic string rule had been violated. You are
correct that the '' character is \\ in a string. No concatenation operators
are necessary. After playing around a little, the following connection
string worked.
"Persist Security Info=False;Integrated Security=SSPI;"
"Data Source=COMP\\DEV_SQL;" //or "Server=COMP\\DEV_SQL;" also worked
"Initial Catalog=My_DB;
Once again, sleep deprivation has given me a swift kick in the pants!
Thanks for your help,
M

> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx|||Hello,
I too am having a problem connecting to a Remote SQL Server 2000 database
from the SQL Server Express Edition Management Studio. The connection fails
with the following error:
TITLE: Connect to Database Engine
--
Cannot connect to INLD50045677A.
ADDITIONAL INFORMATION:
An error has occurred while establishing a connection to the server. When
connecting to SQL Server 2005, this failure may be caused by the fact that
under the default settings SQL Server does not allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection to
SQL Server) (Microsoft SQL Server, Error: 1326)
For help, click:
http://go.microsoft.com/fwlink?Prod...26&LinkId=20476
BUTTONS:
OK
--
Do I need to make any additional settings. AFAIR, there was no such setting
required in 2000. Am I missing anything here?
Regards,
Niranjan|||On Wed, 30 Aug 2006 02:25:01 -0700, Niranjan wrote:

>Hello,
>I too am having a problem connecting to a Remote SQL Server 2000 database
>from the SQL Server Express Edition Management Studio. The connection fails
>with the following error:
(snip)
>Do I need to make any additional settings. AFAIR, there was no such setting
>required in 2000. Am I missing anything here?
Hi Niranjan,
Indeed. Fr security reasons, SQL Server 2005 is configured to not allow
outside connections by default.
To enable outside connections, start the Surface Area Configuration tool
(Start / All Programs / Microsoft SQL Server 2005 / Configuration Tools
/ SQL Server Surface Area Coonfiguration), click Service Area
Configuration for Services and Connections, select the {instancename} /
Database Engine / Remote Connections entry and change the setting from
"Local connections only" to "Local and remote connections". Then, check
if you want to allow TCP/IP only, named pipes only, or both. Click OK,
close the Surfacce Area Configuration tool and restart the instance.
Hugo Kornelis, SQL Server MVP

Monday, March 19, 2012

need assistance on connecting to sql server

Connect to Sql Server[vbcol=seagreen]
Connect using:
[ ] Window authentication
[ ] Sql Server authentication
Login Name : [____________]
Password : [____________]
----
--
I want to get the above senario for sql server name and connect using
different authentication from dos mode using Visual dialog script or winbatc
h
program.
Is there any way to get the following from dos prompt or using sql command
or using registry key --
* server name
* connect using >>>
*-- Window authentication
*-- Sql Server authentication
if Sql Server authentication
then check for user and password
--
Makes Yor Life Easy,MicrosoftHey i got it guys .,.,take it easy .,i found the way in osql
in command prompt type the following steps
if you want the connection in window authentication
c:\>osql -E -i *.txt -o *.txt -n -dmaster
if you want the connection in sql authentication
c:\>osql -U username
password :
> select * from master
>exit
Or
c:\>osql -Uusername -Ppassword -i *.txt -o *.txt -n -h-1 -dmaster
Makes Yor Life Easy,Microsoft
"MrRAO" wrote:

> Connect to Sql Server
> Connect using:
> [ ] Window authentication
> [ ] Sql Server authentication
> Login Name : [____________]
> Password : [____________]
> ----
--
> I want to get the above senario for sql server name and connect using
> different authentication from dos mode using Visual dialog script or winba
tch
> program.
> Is there any way to get the following from dos prompt or using sql command
> or using registry key --
> * server name
> * connect using >>>
> *-- Window authentication
> *-- Sql Server authentication
> if Sql Server authentication
> then check for user and password
> --
> Makes Yor Life Easy,Microsoft