Why Can't I Connect To SQLServer With An Incomplete Conn. String ?
Dec 23, 2004
I found out that I could use SQLDMO to enumerate objects in a SQL server. However, I can't connect to my server, even though I have both "windows and SQL server" authentication on "(local) Windows NT".
Here is the code (it does not contain the validation in this snippet):
Imports System.Data.SqlClient
Imports SQLDMO
Public Class ADO_2
Inherits System.Web.UI.Page
Protected WithEvents txtQuery As System.Web.UI.WebControls.TextBox
Protected WithEvents txtresults As System.Web.UI.WebControls.TextBox
Protected WithEvents lstDB As System.Web.UI.WebControls.DropDownList
Protected WithEvents lblResult As System.Web.UI.WebControls.Label
Protected WithEvents cmdExecute As System.Web.UI.WebControls.Button
Protected WithEvents cmdNext As System.Web.UI.WebControls.Button
Private m_objConn As New SqlConnection()
Private m_objSQLServer As SQLDMO.SQLServer
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
EnumerateDatabases()
'TEMP
lstDB.Items.Add("Northwind")
lstDB.Items.Add("Pubs")
'END TEMP
End Sub
Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Unload
m_objConn.Close() 'Just in case.....
End Sub
Private Sub cmdExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExecute.Click
Dim objCommand As SqlCommand
Dim objDataReader As SqlDataReader
Dim intField As Integer
txtresults.Text = String.Empty
m_objConn.ConnectionString = "server=radu;database=" & lstDB.SelectedItem.Text & ";integrated security=SSPI;"
m_objConn.Open()
objCommand = New SqlCommand(txtQuery.Text, m_objConn)
objDataReader = objCommand.ExecuteReader
While objDataReader.Read
txtresults.Text &= vbNewLine
For intField = 0 To objDataReader.FieldCount - 1
txtresults.Text &= objDataReader(intField).ToString.PadRight(15)
Next
End While
objDataReader.Close()
objDataReader = Nothing
objCommand = Nothing
m_objConn.Close()
End Sub
Private Sub EnumerateDatabases()
On Error GoTo EnumerateDatabasesError
Dim objSQLDatabase As SQLDMO.Database
m_objSQLServer = New SQLDMO.SQLServer()
m_objSQLServer.Connect("radu")
'Iterate through all databases on the target server:
For Each objSQLDatabase In m_objSQLServer.Databases
lstDB.Items.Add(objSQLDatabase.Name)
Next objSQLDatabase
EnumerateDatabasesExit:
objSQLDatabase = Nothing
m_objSQLServer.Close()
m_objSQLServer = Nothing
Exit Sub
EnumerateDatabasesError:
lblResult.Text = Err.Number.ToString & ", " & Err.Description
Resume EnumerateDatabasesExit
End Sub
End Class
Why can't I connect with m_objSQLServer.Connect("radu") ? I also tried m_objSQLServer.Connect("radu", "", ""). Otherwise, I can connect just fine with m_objConn.Open() (after I select a db from the dropdownlist, which is for now populated by hand)....
Thanks a lot for your time.
Alex.
View 1 Replies
ADVERTISEMENT
Feb 22, 2006
Hi
I've been trying to get DotNetNuke to connect to a SQLServer Express database but no luck. I've had no luck with info from their forums...
The connection string I'm supposed to use is:
<add
name="SiteSqlServer"
connectionString="Data Source=.SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Database.mdf;"
providerName="System.Data.SqlClient" />
I just can't get it to connect to the database. Says something that remote connections are not allowed. I've done the Area thing and allowed all connection including remote connections.
Can't we use the standard string like:
<add
name="SiteSqlServer"
connectionString="Server=(local);Database=DotNetNuke;uid=;pwd=;"
providerName="System.Data.SqlClient" />
...to connect? I'd like to setup a user and give the username and password in the connection string - real easy and non-complicated...
Any ideas or help?
Andre
View 3 Replies
View Related
Sep 3, 1999
I have IIS4/ASP on one server (Nomad) and SQL7 on another server (Reliant) in a rack. I am attempting to retrieve records from a table.
I am using this dsnless connection script and I am receiving a login failure:
http://204.84.96.168/wcc/trustees/default.asp
set con1 = createObject("ADODB.connection")con1.open "Provider=sqloledb;Server=204.84.96.99;Database=wc c;UID=andy;PWD=sterling;"
set rs=con1.Execute (sql)
I have set up a new login called andy with the above password and associated the login with the wcc database and the one table that I want to pull data from AND given the login db_creator permissions and checked all of the "select, edit, delete. etc" options.
However when I view who has OWNER status of the wcc database it still reflects the user dbo. Could this be the problem? If so, how do I fix it?
Your help is greatly appreciated!
Andy
View 2 Replies
View Related
Feb 21, 2008
Problem:
i have configure a SSIS package in BIDS to use an Env. Var. to store the location of the .dtsconfig file for the connection to my SSIS configuration table in SQL. I than use another Env. Var. to retrieve the source conn. str. from my SQL SSIS configuration table. Once my package loads, i select a simple sql task to execute, but it comes back and says that it cannot make the connection. How does the SQLServer connection string know what password to use? This is where i'm confused. I believe it loads the connection string for my source database but it doesn't get the password. I just started working in SSIS and i'm trying to get my head around all of the dynamic options of SSIS. I appreciate your time and help.
Problem Details:
package A has 1 sql execute task
Env.Var. 1 stores the location of the .dtsconfig file that stores the connection data to ssis sqlserver configuration table (used to store additional package properties in sql server)
Env. Var. 2 stores the connection string of my source database.
package protection level set at "EncryptSensitiveWithPassword"
the sql task is assigned to the source connection string,right click and execute task.
here is the error:
Failed to acquire connection "source database" Connection may not be configured correctly or you may not have the right permission on this connection.
I'm executing this from within BIDS just to check that my setup is going to work.
Here are some items i've tried or troubleshoot:
1. If I roll back the 2 package Configs or disable using package configs and replace my original source connection manager and create a new connection manager than i can get the sql task to successfully execute again. It won't usually work by just disable the package configs. i had to delete the existing source connection manager.
2. create a new package trying the same steps as above.
3. change the package protection level to "encryptSensitiveWithPassword" expecting this to retain the source connection password. I tried a variety of package protection levels.
Thoughts???? help.....please....
View 9 Replies
View Related
Dec 26, 2004
My MS SQL Server was working perfectly fine locally when I used the following connection string:
server=(local)\DB;Integrated Security=True;uid=;pwd=;database=AspNetDb
When I moved my SQL server to another machine within my LAN, it stopped functioning.
server=(192.168.1.3)\DB;IntegratedSecurity=True;uid=;pwd=;database=AspNetDb
Could someone kindly give me some advice? I appreciate your assistance.
View 1 Replies
View Related
Mar 12, 2007
What is the impact of the differences in the following 2 connection strings:
Initial Catalog=xxx;Data Source=xxxxxx;Trusted_Connection=True;
Driver={SQL Server};Server=xxxxx;database=xxx;Trusted_Connection=yes;
To outline the differences I'm concerned with are
Missing Driver on first string
Difference in Trusted_Connection parameter (true vs. yes)
Initial Catalog vs. database parameter
View 1 Replies
View Related
Dec 16, 2007
Just installed AJAX for VS2005 and started to build a AJAX enabled web site. I got the following message after creating a database (SQL) and Dataset "FOLLOWING ERROR OCCURED WHLE GETTING CONNECTION STRING INFORMATION FROM CONFIGURATION:'CANNOT GET WEB APPLICATION SERVICE'.
I didn't have this problem before,can it be related to AJAX?
Thank you in advance,
View 1 Replies
View Related
Dec 27, 2007
I have a unix shell script. I need to establish connection to the MS SQL server to execute packages and jobs. Could you please help me out on how to establish this connection as I am new to SQL server. I am using SQL Server 2000.
Thanks,
T.
View 6 Replies
View Related
Dec 19, 2007
Hello everyone,
I have the sql connection string configured in my web application as
data source=(local); provider=sqloledb.1; user id=<<user id>>; password=<<password>>; database=<<database>>
My understanding is that when (local) is used, the connection method will fall to shared memory / named pipes. I have names pipes and TCP/IP enabled in the configuration manager.
My machine is also running Comodo Firewall .
Now this is what is happening. When I try to access the asp.net application, I get a component exception in comodo firewall that indicates w3wp.exe is trying to access the sql server via the machine's IP over port 1433. This happens when I try to load the application in the browser.
What I dont understand is that when (local) is configured, it should only access thru shared memory / named pipes. Why is it trying to connect thru TCP port. Is this because I have the sql username and password? My SQL server is configured for mixed mode authentication.
Thanks
RK
View 5 Replies
View Related
Oct 16, 2007
i can't connect sqlserver from client pc
please help me >>>>>>>>>>>>>>>>>>
hi all
View 1 Replies
View Related
Feb 17, 2006
when sqlcmd -s serverinstance cmd is given it geves an error that "under default settings sql server does not allow remote connections login timeout expired"
why sql browser not running
pls help
View 1 Replies
View Related
May 14, 2007
After several attempts to install SQL2005 I finally got Microsoft SQL Server Management Studio installed.But now I get the error below: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) (.Net SqlClient Data Provider)The sa account username/password are correct and don't work, windows authentication does not work, I have stopped/started all the services, I have all Protocols enabled correctly, I have my Firewall turned off. Is there anything else I can try? Anything!
View 1 Replies
View Related
Aug 9, 2004
This is the code I'm using on the web page located on the server:
Dim strConn as String
Dim conn as SQLConnection
strConn="server=localhost;Trusted_Connection=Yes;database=CIS"
conn=New SQLConnection(strConn)
conn.Open()
and the error messgae I receive is: Login failed for user 'MSP00427ASPNET'.
msp00427 is the name of the server
= = = = = = = = =
I have an MSAccess application that accesses the same database as follows with no trouble.
glblConnectString = "Driver=SQL Server;Server=msp00427;Database=CIS;Trusted_Connection=Yes"
Set cnn = New ADODB.Connection
cnn.Open glblConnectString
Set cmd = New ADODB.Command
cmd.ActiveConnection = cnn
cmd.CommandText = "Scorecard_Delete_ATLASDataDump"
cmd.CommandType = adCmdStoredProc
cmd.Execute
This is run on my PC and I have sa capabilities on the server.
The .NET framework is installed.
Any ideas why the data access on the web page fails?
View 3 Replies
View Related
Oct 18, 2005
Hi All,I hopen this isnt a stupid question but can I connect asp 1 to sqlserver 2005? i want to update the database used on a ASP.net 1 project, I seem to be able to get it to connect but cant get it to see the tables?Thanks for any helpLee
View 5 Replies
View Related
Dec 31, 2007
unable to connect to sqlserver, server not found error ... i typed the right username and password,,, still i am not able to connect to sqlserver ,,also i tried with new sqlserver registration still i am not able to connect to sqlserver
error :
specified sqlserver not found connection connect()
please help me out
View 2 Replies
View Related
Jul 23, 2007
In SQLserver Admin, ANDONASPNET is setup as a 'Server Admin'
****************************************************************************
Connection string is set in the web.config file.
<configuration>
<connectionStrings>
<add name="SqlServerEx"
connectionString="Data Source=LOCALHOSTSQLEXPRESS;Initial Catalog=DB2;Integrated Security=SSPI;"
providerName="System.Data.SqlClient;"></add>
</connectionStrings>
<appSettings/>
<system.web>
.......................................................................
protected void Button2_Click(object sender, EventArgs e)
{
string connStr = WebConfigurationManager.ConnectionStrings["SqlServerEx"].ConnectionString;
SqlConnection con = new SqlConnection(connStr);
TextBox3.Text = connStr;
try
{
con.Open();
TextBox2.Text = "<b> Server Verison::</b>" + con.ServerVersion;
TextBox2.Text += "<br /><B>Connection Is::</B> " + con.State.ToString();
}
catch (Exception err)
{
TextBox2.Text = "Error reading Database. ";
TextBox2.Text += err.Message;
}
finally
{
con.Close();
TextBox2.Text += "<BR><B>CONNECTION::" + con.State.ToString() + "</B>";
}
}
****************************************************************************
This is the error message I am getting:
"Error reading Database. Instance failure."
View 1 Replies
View Related
Feb 28, 2008
Hi all,
I'm not a db guru and probably this is a very simple question for you, but I was wondering if it was possible to connect to a SqlServer using odbc without DSN.
I mean, I'm trying to connect to the db server from a linux (Fedora Core 8) workstation, using odbc drivers, but it looks like I can do that only using a DSN connection and setting properly the odbc.ini file. It doesn't work, if I use a connection like this from a PHP script:
$cn = odbc_connect("Driver={SQL Server};Server=MyServer;Database=MyDatabase",
"MyUser","MyPassword")
Does anyone know how to connect to SqlServer with a DSN-less connection? Could you explain me where is the error?
I'm using SQLServer2005, Fedora Core 8 with the last FreeTDS installed.
Please help!
Thanks million in advance.
View 7 Replies
View Related
Jun 25, 2007
Hi
im trying to connect to sqlserver 2005 using windows authentication and gives me this error "Login failed for user ''. The user is not associated with a trusted SQL Server connection."
any help
thanks in advance.
View 3 Replies
View Related
Dec 28, 2007
Hi.
i got an error when i connect to sqlserver 2005 db with use of Sqlserver ManagementStudio.
A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - The specified network name is no longer available.) (.Net SqlClient Data Provider)(Microsoft Sql Error - 64)...
View 4 Replies
View Related
Feb 6, 2007
Currently I cannot connect to a database, I got the system.exception €śPlatformNotSupportedExcoption€?. This database is Polish (COLLATE Polish_CI_AS), when I collate this database to latin general it works fine. I connect by using the system.data.sqlclient.sqlconnection, as far as I can see I cannot set the locale identifier here€¦ What can I do???
Thanks for your help!
regards, Jan
View 3 Replies
View Related
Nov 17, 2006
hi ..
i install sqlserver and make app with vb6 using ADO to connect to the database and successfully
i put that application on another pc on the network
when i open it it says "can't login computernameguest" ??!!
any help
thanks in advance.
View 10 Replies
View Related
Aug 19, 2006
Hi all,
I have Sql Server 2000 installed in my home and also i have a website that works with Sql Server2000 and .Net FrameWork v1.1 ,now i want to know is it possible to connect from my home SqlServer to Host SqlServer( where my Website resides ) through Enterprise manager or Query Analizer to do some data-manipulation And how?
Thanks in advance.Regards.
View 1 Replies
View Related
Mar 13, 2008
Does SQLServer go to sleep when it's been idle? How can I connect without an error?
I have SQLExpress on a server. Server Name is SqlExpress. I have 2 DBs on that server... Tuna & Guppy. I'm connecting to the DBs from a remote PC which runs my App... an exe created with Visual Studio 2008, Visual Basic.
If I run my App at say 9:30PM, after the server has been idle for several hours, I get a "Can't open connection to Guppy" error, which is my error message when the connection attempt fails. If I quit & relaunch the app, it connects fine, and will continue connecting fine unless you leave the server idle for serveral hours again.
If I'm developing a 2nd app all evening... which connects to a 2nd DB...Tuna, that activity seems to keep the SqlServer awake and then launching the 1st app at 9:30PM connects to Guppy just fine.
I tried adding a "Connection Timeout=30" to my connection string but that did not help.
My connection code is as follows (note the server's name is SQLExpress):
Dim strConnG As String = "Data Source=SQLEXPRESSSQLEXPRESS;Initial Catalog=Guppy;Integrated Security=True;Connection Timeout=30"
Using ConnG As New SqlConnection(strConnG)
'open Guppy connection
Try
ConnG.Open()
Catch ex As Exception
MsgBox("Can't open connection to guppy")
Return False
End Try
'Code that does stuff
End using
Can anyone tell me how to fix this so I can connect without error, even if the server has been idle?
Thank you,
Joe A
View 6 Replies
View Related
Sep 10, 2007
Hi,
iam having vs2005 installed on my machine and i also installed sqlserver2005 dev edition on my machine...Unable to connect to Sqlserver 2000 which is installed remotely ....Sqlserver2000 is dev edition.i cudnot find Sqlserver2000 instance when i try to search for Network database engine name .......
I feel to know how to enable remote connection on Sqlserver 2000.So tht i can access this sqlserver2000 from another machine
View 1 Replies
View Related
Sep 28, 2007
i have some oledb code made in c#(vs 2005) it is for local msaccess file. i want to conevert the code for sql server where connection string placed in web.config file seperately. please help me.here is code private void buildGrid()
{
string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
conStr += Server.MapPath("~/common/db/demo.mdb");
System.Data.OleDb.OleDbConnection dbCon = new System.Data.OleDb.OleDbConnection(conStr);
dbCon.Open();
string sql = "SELECT * FROM Posts ORDER BY LastPostDate DESC";
System.Data.OleDb.OleDbDataAdapter dbAdapter = new System.Data.OleDb.OleDbDataAdapter(sql, dbCon);
DataSet ds = new DataSet();
dbAdapter.Fill(ds);
ds.Tables[0].TableName = "Inbox";
Grid1.DataSource = ds;
}
please healp me..
View 3 Replies
View Related
Feb 27, 2006
hi guys,
i am very happy that i found this forum which discuss ASP.net.i am new to ASP.net 2.0 and some need serious help. when i debug my application and try to insert data an error occur saying:"Cannot open database "ecb" requested by the login. The login failed. Login failed for user 'HOME-USERuser'."the code that i have used to submit data is as follow:Imports System.Data.SqlClient... Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Dim objConn As SqlConnection Dim objCmd As SqlCommand
objconn = New SqlConnection("data source= localhostsqlexpress; initial catalog =ecb; persist security info =true; trusted_connection=true")
objCmd = New SqlCommand("INSERT INTO staff (firstname, surname) VALUES (@firstname, @surname,)", objConn)objCmd.Parameters.Add("@FirstName", Data.SqlDbType.VarChar).Value = txtFirstName.TextobjCmd.Parameters.Add("@Surname", Data.SqlDbType.VarChar).Value = txtSurname.TextobjConn.Open()objCmd.ExecuteNonQuery()objConn.Close()
i also used this data connection but didn't help: objconn = New SqlConnection("Server=localhost; Database=ecb;user ID=' ';Password=' ' ") when i use this data
connection i get this message: Login failed for user ''. The user is not associated with a trusted SQL Server connection.
as far as i can remember i have used windows authentication when creating my database in sql server 200 express edition.
the funny thing is that when i use datagrid wizard or dataform the connection is fine ( i mean is automatically done for me but i don't know when i like to do it manually does not work).can anyone help? thank you in advanced
View 5 Replies
View Related
Oct 31, 2007
How to Connect sqlServer 2000 in Pocket PC 2003 Application.
In Packet PC 2003 Application I have to connect to sql server 2000 on
my machine. The application gives error if connected using sqlConnection. Is SQL server CE necessary to connect to sql server 2000 in .Net Compact Framework?
View 1 Replies
View Related
Mar 6, 2007
I have to supply a sqlserver connection string in the format:
ip address:port, how do i go about finding out what the port number is on the sqlserver server ??? This is for an R25 collegent interface connection, if that helps .
View 3 Replies
View Related
Aug 23, 2000
HI ALL,
I am executing a stored procedure (SQL7) which works fine in Query Analyser, but returns only a partial result set to my ASP application:
Query:
SELECT <some fields> FROM <table> WHERE <field> IN ('<text1>','<text2>','<text3>')
My ASP renders the returned recordset, but only results for the <text1> match are displayed!
I had an idea that I may be receiving multiple recordsets from the sp, so I added:
<% Do Until rS Is Nothing
Do While Not rS.Eof %>
----render rows to table here
<% rS.MoveNext
Loop
set rS = rS.NextRecordset
Loop %>
... to no avail.
I even tried changing my SELECT to use <field>='<text1>' OR <field>='<text2>' OR <field>='<text3>'
... same problem
Anyone know where my data is 'hiding'???
Cheers,
Graeme
View 1 Replies
View Related
Aug 31, 2005
For nearly 6 wks I have been trying to workout with GoDaddy.com a connection string that will connect to the SQL Server 2000 from my ASP.Net web application. In my programming, I have placed the connection string in the web.config file and then call it from there within code behind using the SQLConnection object. My web.config entry has the following form:
<appSettings>
<add key="Conn" value="server=GoDaddyserver;integrated security=SSPI;database=databaseonGoDaddyserver;" />
</appSettings>I have also written the key supplying the UID and pwd. Nothing works and their support is of no help.Has anyone else had this difficulty either in general or with GoDaddy in particular?
View 15 Replies
View Related
Apr 24, 2008
CREATE FUNCTION [dbo].[Compare]
(
@usrVal varchar(100),
@dbVal varchar(100)
)
RETURNS BIT
AS
BEGIN
DECLARE @flag BIT
DECLARE @userStrLen INT
DECLARE @dbStrlen INT
DECLARE @counter INT
--Default assignments
SET @counter=1
Set @userStrLen=len(@usrVal)
Set @dbStrlen=len(@dbVal)
IF (@userStrLen != @dbStrlen)
BEGIN
return 0
END
ELSE
BEGIN
WHILE @counter <= @userStrLen
BEGIN
IF (substring(@usrVal,@counter,1) != substring(@dbVal,@counter,1))
RETURN 0
SET @counter = @counter + 1
END
return 1
END
RETURN @flag
--SELECT dbo.Compare('sqlserver user defined functions','sqlserver is the best backend')
END
View 2 Replies
View Related
Jul 23, 2005
I need to conect my software from a remote client to a server, mystandard connection:Provider=SQLOLEDB.1;Persist Security Info=False;UserID=sa;Password=;Initial Catalog=MyDb;DataSource=192.168.0.100;Network=DBMSSOCN;andProvider=SQLOLEDB.1;Persist Security Info=False;UserID=sa;Password=;Initial Catalog=MyDb;DataSource=192.168.0.100;Network=DBNMPNTW;make a error connection,i have tryed with ODBC connection and its OK only in Named Piped.Can any one help me write the right connection string?thanksrm
View 2 Replies
View Related
Jul 20, 2005
Hi SQL Server Experts,I really need some help ASAP.I thank you in advance.We have an ASP/MS SQL Server Shopping cart application,developed by anindependent developer.We really have a problem where the Order_detailsare not getting stored completely.The concerned Tables are:Table1 Order_InfoStores Order_ID,customer data,Total_Amount,Shipping details etc.(One Record per Order.)Table2 Order_detailsStores Order_ID,Product_Id,Price and Quantity.(Multiple Records per Order.Basically stores the shopping cart items,one by one.)Table3 Payment_InfoStores Order_ID and Transaction Details(One Record per Order.)Now after a customer checks out and the payment transaction has beenapproved the order details are stored this way.Step 1: First a new record is added to Table1 (Order_Info).Step 2: A 'For' loop adds new records - one for each item in the cart-to Table2(Order_details).Step 3: A new record is added to the Table3 (Payment_Info).Recently, we have been having problems with Step 2, where only apartial list of the item details are stored in the Database and Step 3is not executed at all.And we don't have the problem all the time.What could be the problem with Step 2 where a series of record areadded to a table continuosly? does this make SQL Server "too busy" sothat subsequent Add operations are not done?Can someone see an apparent problem?Any solution is greatly appeciated.Please HELP ME!Thanks.Sriram
View 6 Replies
View Related