Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Newbie on ASP .NET

Newbie on ASP .NET

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasesysadmindata-structuresdebugging
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rylogy
    wrote on last edited by
    #1

    hey I used this sample code from a book of mine but I get this error Error msg: Login failed for user 'IUSR_GAP-PC'. 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 'IUSR_GAP-PC'. Source Error: Line 37: Line 38: // fill the dataset Line 39: dataAdapter.Fill(dataSet, "Customers"); Line 40: SqlCommandBuilder bldr = new SqlCommandBuilder(dataAdapter); Line 41: Code: private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here // Insert page code here if (!IsPostBack) { // create the connection string string strConnection = "server=GAP-PC; uid=IUSR_GAP-PC; pwd=xpst700r; database=northwind"; //create the command string string strCommand = "Select * from Customers"; // create the data set command object and dataset SqlDataAdapter dataAdapter = new SqlDataAdapter(strCommand, strConnection); DataSet dataSet = new DataSet( ); // fill the dataset dataAdapter.Fill(dataSet, "Customers"); SqlCommandBuilder bldr = new SqlCommandBuilder(dataAdapter); // get the table DataTable dataTable = dataSet.Tables[0]; dgCustomers.DataSource = dataTable; dgCustomers.DataBind( ); } } I apreciate if someone helps me

    C 1 Reply Last reply
    0
    • R Rylogy

      hey I used this sample code from a book of mine but I get this error Error msg: Login failed for user 'IUSR_GAP-PC'. 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 'IUSR_GAP-PC'. Source Error: Line 37: Line 38: // fill the dataset Line 39: dataAdapter.Fill(dataSet, "Customers"); Line 40: SqlCommandBuilder bldr = new SqlCommandBuilder(dataAdapter); Line 41: Code: private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here // Insert page code here if (!IsPostBack) { // create the connection string string strConnection = "server=GAP-PC; uid=IUSR_GAP-PC; pwd=xpst700r; database=northwind"; //create the command string string strCommand = "Select * from Customers"; // create the data set command object and dataset SqlDataAdapter dataAdapter = new SqlDataAdapter(strCommand, strConnection); DataSet dataSet = new DataSet( ); // fill the dataset dataAdapter.Fill(dataSet, "Customers"); SqlCommandBuilder bldr = new SqlCommandBuilder(dataAdapter); // get the table DataTable dataTable = dataSet.Tables[0]; dgCustomers.DataSource = dataTable; dgCustomers.DataBind( ); } } I apreciate if someone helps me

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Rylogy wrote: hey I used this sample code from a book of mine but I get this error So, did the book not explain that the security set up on your machine will be different and to alter the code accordingly? If it didn't explain that then you really need to get a better book.

      // create the connection string
      string strConnection = "server=GAP-PC; uid=IUSR_GAP-PC; pwd=xpst700r; database=northwind";

      The line sets up the connection string to the SQL Server, it needs that your machine (or a machine on your network) is called "GAP-PC" (not including the quotes), that there is a user on that machine called "IUSR_GAP-PC", which has the password "xpst700r". If you have not satisfied all of those conditions then the login attempt will fail. The login name "IUSR_GAP-PC" looks like a user name that windows itself would maintain, so you probably really need a trusted connection. A trusted connection means that the SQL Server will trust that Windows has authenticated the user. If you are passing a user name and password then SQL Server expects that it is maintaining the user account and not windows. IMO, it is better to use a Trusted Connection (then you don't have to worry about storing usernames and passwords inside your application). All you need to do is to remove the uid and pwd elements from the connection string. Then add: Integrated Security=SSPI; to the connection string. (remember to delimit each element with a semi-colon) Unless you have overridden the security for that user account in IIS it should work. Otherwise you might have to dig around in IIS to correct other problems. Does this help?


      Do you want to know more? WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups