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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. I need a lolution for Connection String.

I need a lolution for Connection String.

Scheduled Pinned Locked Moved ASP.NET
databasecsharpsql-serversysadmin
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.
  • T Offline
    T Offline
    tranglt
    wrote on last edited by
    #1

    Hi Everyone! I have a proplem of connection string to connect database I have a SQL server, thi Name server this MSSQLxxx; (Not Local) User: Xman; Pass: Xmankk; DataBase: TLxxx; Now, I Dev a website in .Net 1.x & SQLSERVER 2000. I use a connection string: "user id=Xman;pwd=Xmankk;data source=MSSQLxxx;initial catalog=TLxxx;timeout=90" But, can not connect to database. I try doing connect to the database by tool of sqlserver 2000, it is sucessful, I can view all information of the data (TLxxx), I can view Tables, views ,... I can Create table there. This is the my code: public class UserDB { private string connectionString; public UserDB() { // I try Hardcode to test connection string. connectionString = "user id=Xman;pwd=Xmankk;data source=MSSQLxxx;initial catalog=TLxxx;timeout=90";//ConfigurationSettings.AppSettings["connectionString"]; } public int GetUserID(string userName, string pass) { SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand("TL_GetUserID", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@userName", SqlDbType.NVarChar,50)); cmd.Parameters["@userName"].Value = userName; cmd.Parameters.Add(new SqlParameter("@password", SqlDbType.NVarChar,32)); cmd.Parameters["@password"].Value = pass; try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow); if (reader.Read()) { return Convert.ToInt32(reader["UserID"]); } else { return -1; } } catch(SqlException) { throw new ApplicationException("data "); } finally { con.Close(); } return -1; } .... } Please, show me solution. Many Thank. I Don't Want Say No Wealth

    E 1 Reply Last reply
    0
    • T tranglt

      Hi Everyone! I have a proplem of connection string to connect database I have a SQL server, thi Name server this MSSQLxxx; (Not Local) User: Xman; Pass: Xmankk; DataBase: TLxxx; Now, I Dev a website in .Net 1.x & SQLSERVER 2000. I use a connection string: "user id=Xman;pwd=Xmankk;data source=MSSQLxxx;initial catalog=TLxxx;timeout=90" But, can not connect to database. I try doing connect to the database by tool of sqlserver 2000, it is sucessful, I can view all information of the data (TLxxx), I can view Tables, views ,... I can Create table there. This is the my code: public class UserDB { private string connectionString; public UserDB() { // I try Hardcode to test connection string. connectionString = "user id=Xman;pwd=Xmankk;data source=MSSQLxxx;initial catalog=TLxxx;timeout=90";//ConfigurationSettings.AppSettings["connectionString"]; } public int GetUserID(string userName, string pass) { SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand("TL_GetUserID", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@userName", SqlDbType.NVarChar,50)); cmd.Parameters["@userName"].Value = userName; cmd.Parameters.Add(new SqlParameter("@password", SqlDbType.NVarChar,32)); cmd.Parameters["@password"].Value = pass; try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow); if (reader.Read()) { return Convert.ToInt32(reader["UserID"]); } else { return -1; } } catch(SqlException) { throw new ApplicationException("data "); } finally { con.Close(); } return -1; } .... } Please, show me solution. Many Thank. I Don't Want Say No Wealth

      E Offline
      E Offline
      enjoycrack
      wrote on last edited by
      #2

      Just wonder what the expection you got? << >>

      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