Showing posts with label connect. Show all posts
Showing posts with label connect. Show all posts

Monday, March 19, 2012

Im not able to connect to SQL server using ASP.NET & VS.NET

plzz help me ,
I use VS.NET --> VB.NET --> ASP.NET appln.

Database : Nortwind using SQL data adapter

And plzz let me know what are steps in connecting to database.

I've tried something but i'm getting " Login failed for user 'HOME-HG0B8FTI7Y\ASPNET'. "
error.

Some1 out dere solve this problem

Server Error in '/WebApplication6' Application.
------------------------

Login failed for user 'HOME-HG0B8FTI7Y\ASPNET'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'HOME-HG0B8FTI7Y\ASPNET'.

Source Error:

Line 89: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Line 90: 'Put user code to initialize the page here
Line 91: Me.SqlDataAdapter1.Fill(Me.DataSet11.Categories)
Line 92: Me.DataBind()
Line 93: End Sub

Source File: d:\inetpub\wwwroot\WebApplication6\WebForm1.aspx.vb Line: 91

Stack Trace:

[SqlException: Login failed for user 'HOME-HG0B8FTI7Y\ASPNET'.]
System.Data.SqlClient.SqlConnection.Open()
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataTable dataTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
WebApplication6.WebForm1.Page_Load(Object sender, EventArgs e) in d:\inetpub\wwwroot\WebApplication6\WebForm1.aspx.vb:91
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()Hi there,

This happens when asp.net user account doesn't have enough permissions to access the specified database. Try thislink

Hope this helps|||It is eating my brain. U gave right solution|||Glad it worked for you...

Have fun programming..:)

I''m not able to connect to my SQL server with SQLconnect

Hi,

I'm using the SQLconnect function in order to connect to my SQL server

I want to connect to a database called "CookieJar" without user name and password

this is the code:

#include "Container.h"

#include <windows.h>

#include <sqlext.h>

int main()

{

HENV hEnv = NULL; // Env Handle from SQLAllocEnv()

HDBC hDBC = NULL; // Connection handle

HSTMT hStmt = NULL;// Statement handle

UCHAR szDSN[1024] = "CookieJar";// Data Source Name buffer

UCHAR szUID[10] = "";// User ID buffer

UCHAR szPasswd[10] = "";// Password buffer

UCHAR szModel[128];// Model buffer

SDWORD cbModel;// Model buffer bytes recieved

char buff[9] = "Testing";

UCHAR szSqlStr[128]= "INSERT into (Tablename) (ColumnName) Values ('Testing')" ;

RETCODE retcode;

//sprintf((char*)szSqlStr,"INSERT into (Tablename)(Columname) Values ('%s')",buff);

// Allocate memory for ODBC Environment handle

SQLAllocEnv (&hEnv);

// Allocate memory for the connection handle

SQLAllocConnect (hEnv, &hDBC);

// Connect to the data source "test" using userid and password.

retcode = SQLConnect (hDBC, (SQLWCHAR*)szDSN, SQL_NTS,/* (SQLWCHAR*)szUID*/ NULL, SQL_NTS, /*(SQLWCHAR*)szPasswd*/ NULL, SQL_NTS);

if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)

{

// Allocate memory for the statement handle

retcode = SQLAllocStmt (hDBC, &hStmt);

// Prepare the SQL statement by assigning it to the statement handle

retcode = SQLPrepare (hStmt, (SQLWCHAR*)szSqlStr, sizeof (szSqlStr));

// Execute the SQL statement handle

retcode = SQLExecute (hStmt);

// Project only column 1 which is the models

SQLBindCol (hStmt, 1, SQL_C_CHAR, szModel, sizeof(szModel), &cbModel);

// Get row of data from the result set defined above in the statement

retcode = SQLFetch (hStmt);

// Free the allocated statement handle

SQLFreeStmt (hStmt, SQL_DROP);

// Disconnect from datasource

SQLDisconnect (hDBC);

}

// Free the allocated connection handle

SQLFreeConnect (hDBC);

// Free the allocated ODBC environment handle

SQLFreeEnv (hEnv);

return 0;

}

The program works but it doesn't get into the "if" section...

And what do I need to put in szDSN - just the database name or the whole connection string?

please help,

Thanks,

Eli

Hi Eli,

http://msdn2.microsoft.com/en-us/library/ms711810.aspx

note that the string you are using for database is actually the server name.

If you want to specify the database, call SQLSetConnectAttr() with SQL_ATTR_CURRENT_CATALOG.

Still not sure why you are sending NULL username and password. You may want to use 0 instead of SQL_NTS there, with NULL strings -- not sure if we ignore that or not.

Hope that helps,

John

I''m not able to connect to my SQL server with SQLconnect

Hi,

I'm using the SQLconnect function in order to connect to my SQL server

I want to connect to a database called "CookieJar" without user name and password

this is the code:

#include "Container.h"

#include <windows.h>

#include <sqlext.h>

int main()

{

HENV hEnv = NULL; // Env Handle from SQLAllocEnv()

HDBC hDBC = NULL; // Connection handle

HSTMT hStmt = NULL;// Statement handle

UCHAR szDSN[1024] = "CookieJar";// Data Source Name buffer

UCHAR szUID[10] = "";// User ID buffer

UCHAR szPasswd[10] = "";// Password buffer

UCHAR szModel[128];// Model buffer

SDWORD cbModel;// Model buffer bytes recieved

char buff[9] = "Testing";

UCHAR szSqlStr[128]= "INSERT into (Tablename) (ColumnName) Values ('Testing')" ;

RETCODE retcode;

//sprintf((char*)szSqlStr,"INSERT into (Tablename)(Columname) Values ('%s')",buff);

// Allocate memory for ODBC Environment handle

SQLAllocEnv (&hEnv);

// Allocate memory for the connection handle

SQLAllocConnect (hEnv, &hDBC);

// Connect to the data source "test" using userid and password.

retcode = SQLConnect (hDBC, (SQLWCHAR*)szDSN, SQL_NTS,/* (SQLWCHAR*)szUID*/ NULL, SQL_NTS, /*(SQLWCHAR*)szPasswd*/ NULL, SQL_NTS);

if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)

{

// Allocate memory for the statement handle

retcode = SQLAllocStmt (hDBC, &hStmt);

// Prepare the SQL statement by assigning it to the statement handle

retcode = SQLPrepare (hStmt, (SQLWCHAR*)szSqlStr, sizeof (szSqlStr));

// Execute the SQL statement handle

retcode = SQLExecute (hStmt);

// Project only column 1 which is the models

SQLBindCol (hStmt, 1, SQL_C_CHAR, szModel, sizeof(szModel), &cbModel);

// Get row of data from the result set defined above in the statement

retcode = SQLFetch (hStmt);

// Free the allocated statement handle

SQLFreeStmt (hStmt, SQL_DROP);

// Disconnect from datasource

SQLDisconnect (hDBC);

}

// Free the allocated connection handle

SQLFreeConnect (hDBC);

// Free the allocated ODBC environment handle

SQLFreeEnv (hEnv);

return 0;

}

The program works but it doesn't get into the "if" section...

And what do I need to put in szDSN - just the database name or the whole connection string?

please help,

Thanks,

Eli

Hi Eli,

http://msdn2.microsoft.com/en-us/library/ms711810.aspx

note that the string you are using for database is actually the server name.

If you want to specify the database, call SQLSetConnectAttr() with SQL_ATTR_CURRENT_CATALOG.

Still not sure why you are sending NULL username and password. You may want to use 0 instead of SQL_NTS there, with NULL strings -- not sure if we ignore that or not.

Hope that helps,

John

Friday, March 9, 2012

IIS6 connect to sql server on another machine w/windows authentication

Can someone point me at an article that tells how to allow theASP.net worker process to connect, via windows authentication, to aremote sql server instance ?

Start with:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/PAGHT000008.asp

The remote server access is in the connection string, specifying server and instance.

Jeff

|||

Also make sure remote connections enabled on the remote SQL instnace. Check this KB:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

IIS/MS SQL/ASP... cant connect

I have an ASP script with the following code in the global.asa:

Application("DBConnectString")="DSN=Test_Server;UID=Michael;PWD=xxxx"

But I get the error:

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/TheResort/i_asputils.asp, line 8

Problem:

I setup the ODBC portion and it correctly saw the MS SQL server, and the test connection worked fine. Yet when I ever I enter that ODBC name "Test_Server", and the password of the Win XP Pro user I am signed in as, it fails to connect.

How can I be sure what domain,user,password I need to enter?Ttry using "DSN=asset;UID=;PWD=" and don't forget to insert the user id and password.

Also, when you set up the odbc "system" dsn, remember to click on the test connection button to verify the connection.

http://www.google.com/url?sa=U&start=9&q=http://support.microsoft.com/support/kb/articles/Q169/3/77.asp&e=7415 information.

IIS SQL Server connection error (urgent)

I keep getting this error when I try to connect to my SQL Server DB

Microsoft OLE DB Provider for SQL Server (0x80004005)
Login failed for user 'Administrator'. Reason: Not associated with a trusted SQL Server connection.

when I installed SQL Server I set username and password to windows default which is Administrator and no password

the asp files are on IIS (localhost)

connstr = "Provider=SQLOLEDB;" &_
"Data Source=(local);" &_
"Initial Catalog=ShotWatcher;"&_
"User ID=Administrator;"&_
"Password="

shouldn't this work?

Please Help

JustinDo you have a SQL Server Standard account called Administrator? Or you're trying to use Windows account with the same name? If it's the latter, - remove User ID and Password attributes and replace them with Integrated Security=SSPI.|||And in connection string you should specify TRUSTED_CONNECTION=TRUE and try using servername instead of specifying local.

KBA (http://support.microsoft.com/default.aspx?scid=kb;en-us;306586) to more about it.|||i'll try that, thx

Wednesday, March 7, 2012

IIS 6.0 with sql backend connectivity

Can somebody please send me a link or reference on how to
configure a website using IIS 6.0 to connect to a SQL on
the backend?
Thank you.
Bahij,
the topics you need to check out are ASP, ASP.NET, ADO, ADO.NET (there are
alternatives but this is a good starting place).
Searching for these topics on Google will give loads of decent sites. If you
are stuck, then email me and I can give you a simple demo page which works
against Northwind and you can just stick it in IIS to see the whole thing
working.
Regards,
Paul Ibison
|||Paul,
can you please email me that code sample to bnahhas@.austin.rr.com ?
Thank you so much for your time and effort.
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!
|||Bahij,
actually found this for you on MSDN which is simpler than my example:
http://msdn.microsoft.com/library/de...vbscriptx.asp.
To get it to work, you'll need to add the windows user IUSR_IISCOMPUTERNAME
as a login on your sql server. If IIS and SQL are on the same box, nothing
else is required, but if not you'll need to change the following:
Data Source=" & _
Request.ServerVariables("SERVER_NAME")
to
Data Source=YourSQLServer
HTH,
Paul Ibison

IIS 6.0 with sql backend connectivity

Can somebody please send me a link or reference on how to
configure a website using IIS 6.0 to connect to a SQL on
the backend?
Thank you.Bahij,
the topics you need to check out are ASP, ASP.NET, ADO, ADO.NET (there are
alternatives but this is a good starting place).
Searching for these topics on Google will give loads of decent sites. If you
are stuck, then email me and I can give you a simple demo page which works
against Northwind and you can just stick it in IIS to see the whole thing
working.
Regards,
Paul Ibison|||Paul,
can you please email me that code sample to bnahhas@.austin.rr.com ?
Thank you so much for your time and effort.
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!|||Bahij,
actually found this for you on MSDN which is simpler than my example:
http://msdn.microsoft.com/library/d...evbscriptx.asp.
To get it to work, you'll need to add the windows user IUSR_IISCOMPUTERNAME
as a login on your sql server. If IIS and SQL are on the same box, nothing
else is required, but if not you'll need to change the following:
Data Source=" & _
Request.ServerVariables("SERVER_NAME")
to
Data Source=YourSQLServer
HTH,
Paul Ibison