Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello guys, first of all I would like to say my thanks to all for your help. Now I am facing another problem. My Instructor wanted me to use Microsoft SQL Server 2005. The problem is I don't know how to use it please help me.
Here is my trial code:
XML
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Web.UI" %>

<script language="VB" runat="server">

    Sub btnLogin_OnClick(Src As Object, E As EventArgs)
        Dim strSQL As String
        Dim myCommand As OleDbCommand
        Dim strUserURL As String
        Using connection As New OleDbConnection("datasource1")
            strSQL = "SELECT * FROM [Admin] " _
            & "WHERE LogName='" & Replace(txtUsername.Text, "'", "''") & "' " _
            & "AND LogPass='" & Replace(txtPassword.Text, "'", "''") & "'"
            myCommand = New OleDbCommand(strSQL, connection)
            connection.Open()
            strUserURL = myCommand.ExecuteScalar()
            connection.Close()

            If strUserURL <> "" Then
                lblInvalid.Text = ""
                FormsAuthentication.SetAuthCookie(txtUsername.Text, True)
                Response.Redirect("bob.aspx")
            Else
                lblInvalid.Text = "Sorry... try again..."
            End If

        End Using
    End Sub


</script>

<html>
<head>
<title>ASP.NET Login</title>
</head>
<body>

<h2>Please Login:</h2>

<p>
<asp:Label id="lblInvalid" runat="server" />
</p>

<form runat="server">

    Username: <asp:TextBox id="txtUsername" runat="server" /><br />
    Password: <asp:TextBox id="txtPassword" TextMode="password" runat="server" Width="155px" /><br />
    <br />
    position: &nbsp;&nbsp;
    <asp:TextBox id="items" runat="server" /><br />
    <br />
    <br />
    <asp:Button id="btnLogin" runat="server"
        text="Login" OnClick="btnLogin_OnClick" Width="221px"
    />&nbsp;
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestSQLConnectionString %>"
        SelectCommand="SELECT * FROM [Admin]" OnSelecting="SqlDataSource1_Selecting"></asp:SqlDataSource>
</form>

</body>
</html>


Here is the web.config:
XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

    <!-- enable forms authentication -->
    <system.web>
        <authentication mode="Forms">
            <forms name="ASP101SampleAuth" loginUrl="login_db_nav.aspx" />
        </authentication>
    </system.web>

    <!-- set secure page to reject anonymous users -->
    <location path="bob.aspx">
        <system.web>
            <authorization>
                <allow users="*" />
                <deny users="none" />
            </authorization>
        </system.web>
    </location>


</configuration>


Now here is the error I'm trying to debug:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'SqlDataSource1_Selecting' is not a member of 'ASP.login_db_nav_aspx'.

Source Error:



Line 57:        text="Login" OnClick="btnLogin_OnClick" Width="221px"
Line 58:    />&nbsp;
Line 59:     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestSQLConnectionString %>"
Line 60:         SelectCommand="SELECT * FROM [Admin]" OnSelecting="SqlDataSource1_Selecting"></asp:SqlDataSource>
Line 61: </form>


Source File: C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx    Line: 59



Please help me.. I don't know where I got it wrong..
Posted
Updated 26-Apr-11 21:53pm
v5

Hi,

Please go through with the article
Connect to SQL Server Using SQL Authentication in ASP.NET 2.0

Please check Connection String syntax from this site.
Connection Strings

Regards
AR
 
Share this answer
 
v2
Comments
drkterror1 27-Apr-11 2:43am    
Thanks reading it ^_^
[no name] 28-Jun-11 2:30am    
Good Call. My 5 too.
I know that my code is in logical error. I know that I still have to learn more. But my main problem is even I follow the instruction the problem is still the same here is what I did:
web.config
<pre lang="xml"><?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="connection" connectionstring="Server=TestSQLConnectionString"; database="pubs"; userID="MyUser"; password="password"
         providerName="System.Data.SqlClient"/>

  </connectionStrings>
    <!-- enable forms authentication -->
    <system.web>
        <authentication mode="Forms">
            <forms name="ASP101SampleAuth" loginUrl="login_db_nav.aspx" />
        </authentication>
    </system.web>

    <!-- set secure page to reject anonymous users -->
    <location path="bob.aspx">
        <system.web>
            <authorization>
                <allow users="*" />
                <deny users="none" />
            </authorization>
        </system.web>
    </location>



</configuration>



Is there any wrong in my codes?
Plss help any suggestion is appreciated
 
Share this answer
 
Comments
Ankit Rajput 27-Apr-11 3:05am    
I think, problem is occuring due to Connection String.

I am updating my answer for Connection String purpose.
Ankit Rajput 27-Apr-11 3:06am    
Please mention the error you are getting.
It will help everyone to think about your problem.
<pre lang="msil">Server Error in '/Desktop' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'SqlDataSource1_Selecting' is not a member of 'ASP.login_db_nav_aspx'.

Source Error:



Line 57:        text="Login" OnClick="btnLogin_OnClick" Width="221px"
Line 58:    />&nbsp;
Line 59:     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestSQLConnectionString %>"
Line 60:         SelectCommand="SELECT * FROM [Admin]" OnSelecting="SqlDataSource1_Selecting"></asp:SqlDataSource>
Line 61: </form>


Source File: C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx    Line: 59



Show Detailed Compiler Output:


C:\Program Files\Microsoft Visual Studio 8\Common7\IDE> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\desktop\a41b4701\3dae1420\App_Web_rbtjhzco.dll" /D:DEBUG=1 /debug+ /define:_MYTYPE=\"Web\" /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls  "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\desktop\a41b4701\3dae1420\App_Web_rbtjhzco.0.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\desktop\a41b4701\3dae1420\App_Web_rbtjhzco.1.vb"


Microsoft (R) Visual Basic Compiler version 8.0.50727.3053
for Microsoft (R) .NET Framework version 2.0.50727.3620
Copyright (c) Microsoft Corporation.  All rights reserved.

C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx(53) : warning BC40004: withEvents variable 'items' conflicts with property 'items' in the base class 'Page' and should be declared 'Shadows'.

        Protected WithEvents items As Global.System.Web.UI.WebControls.TextBox
                             ~~~~~
C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx(59) : error BC30456: 'SqlDataSource1_Selecting' is not a member of 'ASP.login_db_nav_aspx'.

            AddHandler __ctrl.Selecting, AddressOf Me.SqlDataSource1_Selecting
                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~





Show Complete Compilation Source:


Line 1:    #ExternalChecksum("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx","{406ea660-64cf-4c82-b6f0-42d48172a799}","D4407A80EBB64CDD2886D98193654E27")
Line 2:    '------------------------------------------------------------------------------
Line 3:    ' <auto-generated>
Line 4:    '     This code was generated by a tool.
Line 5:    '     Runtime Version:2.0.50727.3620
Line 6:    '
Line 7:    '     Changes to this file may cause incorrect behavior and will be lost if
Line 8:    '     the code is regenerated.
Line 9:    ' </auto-generated>
Line 10:   '------------------------------------------------------------------------------
Line 11:
Line 12:   Option Strict Off
Line 13:   Option Explicit On
Line 14:
Line 15:   Imports Microsoft.VisualBasic
Line 16:   Imports System
Line 17:   Imports System.Collections
Line 18:   Imports System.Collections.Specialized
Line 19:   Imports System.Configuration
Line 20:   Imports System.Data
Line 21:   Imports System.Data.OleDb
Line 22:   Imports System.Text
Line 23:   Imports System.Text.RegularExpressions
Line 24:   Imports System.Web
Line 25:   Imports System.Web.Caching
Line 26:   Imports System.Web.Profile
Line 27:   Imports System.Web.Security
Line 28:   Imports System.Web.SessionState
Line 29:   Imports System.Web.UI
Line 30:   Imports System.Web.UI.HtmlControls
Line 31:   Imports System.Web.UI.WebControls
Line 32:   Imports System.Web.UI.WebControls.WebParts
Line 33:
Line 34:   Namespace ASP
Line 35:
Line 36:       <System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()>  _
Line 37:       Public Class login_db_nav_aspx
Line 38:           Inherits Global.System.Web.UI.Page
Line 39:           Implements System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler
Line 40:
Line 41:
Line 42:           #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",44)
Line 43:           Protected WithEvents lblInvalid As Global.System.Web.UI.WebControls.Label
Line 44:
Line 45:           #End ExternalSource
Line 46:
Line 47:
Line 48:           #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",49)
Line 49:           Protected WithEvents txtUsername As Global.System.Web.UI.WebControls.TextBox
Line 50:
Line 51:           #End ExternalSource
Line 52:
Line 53:
Line 54:           #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",50)
Line 55:           Protected WithEvents txtPassword As Global.System.Web.UI.WebControls.TextBox
Line 56:
Line 57:           #End ExternalSource
Line 58:
Line 59:
Line 60:           #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",53)
Line 61:           Protected WithEvents items As Global.System.Web.UI.WebControls.TextBox
Line 62:
Line 63:           #End ExternalSource
Line 64:
Line 65:
Line 66:           #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",56)
Line 67:           Protected WithEvents btnLogin As Global.System.Web.UI.WebControls.Button
Line 68:
Line 69:           #End ExternalSource
Line 70:
Line 71:
Line 72:           #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",59)
Line 73:           Protected WithEvents SqlDataSource1 As Global.System.Web.UI.WebControls.SqlDataSource
Line 74:
Line 75:           #End ExternalSource
Line 76:
Line 77:           Private Shared __initialized As Boolean
Line 78:
Line 79:           Private Shared __fileDependencies As Object
Line 80:
Line 81:
Line 82:           #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",6)
Line 83:
Line 84:
Line 85:    Sub btnLogin_OnClick(Src As Object, E As EventArgs)
Line 86:           Dim strSQL As String
Line 87:           Dim myCommand As OleDbCommand
Line 88:           Dim strUserURL As String
Line 89:           Using connection As New OleDbConnection("SQLdatasource1")
Line 90:               strSQL = "SELECT * FROM [Admin] " _
Line 91:               & "WHERE LogName='" & Replace(txtUsername.Text, "'", "''") & "' " _
Line 92:               & "AND LogPass='" & Replace(txtPassword.Text, "'", "''") & "'"
Line 93:               myCommand = New OleDbCommand(strSQL, connection)
Line 94:               connection.Open()
Line 95:               strUserURL = myCommand.ExecuteScalar()
Line 96:               connection.Close()
Line 97:
Line 98:               If strUserURL <> "" Then
Line 99:                   lblInvalid.Text = ""
Line 100:                  FormsAuthentication.SetAuthCookie(txtUsername.Text, True)
Line 101:                  Response.Redirect("bob.aspx")
Line 102:              Else
Line 103:                  lblInvalid.Text = "Sorry... try again..."
Line 104:              End If
Line 105:
Line 106:          End Using
Line 107:      End Sub
Line 108:
Line 109:
Line 110:
Line 111:          #End ExternalSource
Line 112:
Line 113:
Line 114:          <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Line 115:          Public Sub New()
Line 116:              MyBase.New
Line 117:              Dim dependencies() As String
Line 118:              CType(Me,Global.System.Web.UI.Page).AppRelativeVirtualPath = "~/login_db_nav.aspx"
Line 119:              If (Global.ASP.login_db_nav_aspx.__initialized = false) Then
Line 120:                  dependencies = New String(0) {}
Line 121:                  dependencies(0) = "~/login_db_nav.aspx"
Line 122:                  Global.ASP.login_db_nav_aspx.__fileDependencies = Me.GetWrappedFileDependencies(dependencies)
Line 123:                  Global.ASP.login_db_nav_aspx.__initialized = true
Line 124:              End If
Line 125:              Me.Server.ScriptTimeout = 30000000
Line 126:          End Sub
Line 127:
Line 128:          Protected ReadOnly Property Profile() As System.Web.Profile.DefaultProfile
Line 129:              Get
Line 130:                  Return CType(Me.Context.Profile,System.Web.Profile.DefaultProfile)
Line 131:              End Get
Line 132:          End Property
Line 133:
Line 134:          Protected ReadOnly Property ApplicationInstance() As System.Web.HttpApplication
Line 135:              Get
Line 136:                  Return CType(Me.Context.ApplicationInstance,System.Web.HttpApplication)
Line 137:              End Get
Line 138:          End Property
Line 139:
Line 140:          <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Line 141:          Private Function __BuildControllblInvalid() As Global.System.Web.UI.WebControls.Label
Line 142:              Dim __ctrl As Global.System.Web.UI.WebControls.Label
Line 143:
Line 144:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",44)
Line 145:              __ctrl = New Global.System.Web.UI.WebControls.Label
Line 146:
Line 147:              #End ExternalSource
Line 148:              Me.lblInvalid = __ctrl
Line 149:              __ctrl.ApplyStyleSheetSkin(Me)
Line 150:
Line 151:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",44)
Line 152:              __ctrl.ID = "lblInvalid"
Line 153:
Line 154:              #End ExternalSource
Line 155:              Return __ctrl
Line 156:          End Function
Line 157:
Line 158:          <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Line 159:          Private Function __BuildControltxtUsername() As Global.System.Web.UI.WebControls.TextBox
Line 160:              Dim __ctrl As Global.System.Web.UI.WebControls.TextBox
Line 161:
Line 162:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",49)
Line 163:              __ctrl = New Global.System.Web.UI.WebControls.TextBox
Line 164:
Line 165:              #End ExternalSource
Line 166:              Me.txtUsername = __ctrl
Line 167:              __ctrl.ApplyStyleSheetSkin(Me)
Line 168:
Line 169:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",49)
Line 170:              __ctrl.ID = "txtUsername"
Line 171:
Line 172:              #End ExternalSource
Line 173:              Return __ctrl
Line 174:          End Function
Line 175:
Line 176:          <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Line 177:          Private Function __BuildControltxtPassword() As Global.System.Web.UI.WebControls.TextBox
Line 178:              Dim __ctrl As Global.System.Web.UI.WebControls.TextBox
Line 179:
Line 180:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",50)
Line 181:              __ctrl = New Global.System.Web.UI.WebControls.TextBox
Line 182:
Line 183:              #End ExternalSource
Line 184:              Me.txtPassword = __ctrl
Line 185:              __ctrl.ApplyStyleSheetSkin(Me)
Line 186:
Line 187:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",50)
Line 188:              __ctrl.ID = "txtPassword"
Line 189:
Line 190:              #End ExternalSource
Line 191:
Line 192:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",50)
Line 193:              __ctrl.TextMode = System.Web.UI.WebControls.TextBoxMode.Password
Line 194:
Line 195:              #End ExternalSource
Line 196:
Line 197:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",50)
Line 198:              __ctrl.Width = New System.Web.UI.WebControls.Unit(155, System.Web.UI.WebControls.UnitType.Pixel)
Line 199:
Line 200:              #End ExternalSource
Line 201:              Return __ctrl
Line 202:          End Function
Line 203:
Line 204:          <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Line 205:          Private Function __BuildControlitems() As Global.System.Web.UI.WebControls.TextBox
Line 206:              Dim __ctrl As Global.System.Web.UI.WebControls.TextBox
Line 207:
Line 208:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",53)
Line 209:              __ctrl = New Global.System.Web.UI.WebControls.TextBox
Line 210:
Line 211:              #End ExternalSource
Line 212:              Me.items = __ctrl
Line 213:              __ctrl.ApplyStyleSheetSkin(Me)
Line 214:
Line 215:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",53)
Line 216:              __ctrl.ID = "items"
Line 217:
Line 218:              #End ExternalSource
Line 219:              Return __ctrl
Line 220:          End Function
Line 221:
Line 222:          <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Line 223:          Private Function __BuildControlbtnLogin() As Global.System.Web.UI.WebControls.Button
Line 224:              Dim __ctrl As Global.System.Web.UI.WebControls.Button
Line 225:
Line 226:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",56)
Line 227:              __ctrl = New Global.System.Web.UI.WebControls.Button
Line 228:
Line 229:              #End ExternalSource
Line 230:              Me.btnLogin = __ctrl
Line 231:              __ctrl.ApplyStyleSheetSkin(Me)
Line 232:
Line 233:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",56)
Line 234:              __ctrl.ID = "btnLogin"
Line 235:
Line 236:              #End ExternalSource
Line 237:
Line 238:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",56)
Line 239:              __ctrl.Text = "Login"
Line 240:
Line 241:              #End ExternalSource
Line 242:
Line 243:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",56)
Line 244:              __ctrl.Width = New System.Web.UI.WebControls.Unit(221, System.Web.UI.WebControls.UnitType.Pixel)
Line 245:
Line 246:              #End ExternalSource
Line 247:
Line 248:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",56)
Line 249:              AddHandler __ctrl.Click, AddressOf Me.btnLogin_OnClick
Line 250:
Line 251:              #End ExternalSource
Line 252:              Return __ctrl
Line 253:          End Function
Line 254:
Line 255:          <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Line 256:          Private Function __BuildControlSqlDataSource1() As Global.System.Web.UI.WebControls.SqlDataSource
Line 257:              Dim __ctrl As Global.System.Web.UI.WebControls.SqlDataSource
Line 258:
Line 259:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",59)
Line 260:              __ctrl = New Global.System.Web.UI.WebControls.SqlDataSource
Line 261:
Line 262:              #End ExternalSource
Line 263:              Me.SqlDataSource1 = __ctrl
Line 264:
Line 265:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",59)
Line 266:              __ctrl.ID = "SqlDataSource1"
Line 267:
Line 268:              #End ExternalSource
Line 269:
Line 270:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",59)
Line 271:              __ctrl.SelectCommand = "SELECT * FROM [Admin]"
Line 272:
Line 273:              #End ExternalSource
Line 274:              __ctrl.ConnectionString = System.Convert.ToString(System.Web.Compilation.ConnectionStringsExpressionBuilder.GetConnectionString("TestSQLConnectionString"), System.Globalization.CultureInfo.CurrentCulture)
Line 275:
Line 276:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",59)
Line 277:              AddHandler __ctrl.Selecting, AddressOf Me.SqlDataSource1_Selecting
Line 278:
Line 279:              #End ExternalSource
Line 280:              Return __ctrl
Line 281:          End Function
Line 282:
Line 283:          <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Line 284:          Private Function __BuildControl__control2() As Global.System.Web.UI.HtmlControls.HtmlForm
Line 285:              Dim __ctrl As Global.System.Web.UI.HtmlControls.HtmlForm
Line 286:
Line 287:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 288:              __ctrl = New Global.System.Web.UI.HtmlControls.HtmlForm
Line 289:
Line 290:              #End ExternalSource
Line 291:              Dim __parser As System.Web.UI.IParserAccessor = CType(__ctrl,System.Web.UI.IParserAccessor)
Line 292:
Line 293:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 294:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(9)&"Username: "))
Line 295:
Line 296:              #End ExternalSource
Line 297:              Dim __ctrl1 As Global.System.Web.UI.WebControls.TextBox
Line 298:
Line 299:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 300:              __ctrl1 = Me.__BuildControltxtUsername
Line 301:
Line 302:              #End ExternalSource
Line 303:
Line 304:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 305:              __parser.AddParsedSubObject(__ctrl1)
Line 306:
Line 307:              #End ExternalSource
Line 308:
Line 309:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 310:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl("<br />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(9)&"Password: "))
Line 311:
Line 312:              #End ExternalSource
Line 313:              Dim __ctrl2 As Global.System.Web.UI.WebControls.TextBox
Line 314:
Line 315:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 316:              __ctrl2 = Me.__BuildControltxtPassword
Line 317:
Line 318:              #End ExternalSource
Line 319:
Line 320:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 321:              __parser.AddParsedSubObject(__ctrl2)
Line 322:
Line 323:              #End ExternalSource
Line 324:
Line 325:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 326:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl("<br />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"    <br />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"    position: &nbsp;&nbsp;"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"    "))
Line 327:
Line 328:              #End ExternalSource
Line 329:              Dim __ctrl3 As Global.System.Web.UI.WebControls.TextBox
Line 330:
Line 331:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 332:              __ctrl3 = Me.__BuildControlitems
Line 333:
Line 334:              #End ExternalSource
Line 335:
Line 336:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 337:              __parser.AddParsedSubObject(__ctrl3)
Line 338:
Line 339:              #End ExternalSource
Line 340:
Line 341:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 342:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl("<br />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"    <br />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(9)&"<br />"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(9)))
Line 343:
Line 344:              #End ExternalSource
Line 345:              Dim __ctrl4 As Global.System.Web.UI.WebControls.Button
Line 346:
Line 347:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 348:              __ctrl4 = Me.__BuildControlbtnLogin
Line 349:
Line 350:              #End ExternalSource
Line 351:
Line 352:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 353:              __parser.AddParsedSubObject(__ctrl4)
Line 354:
Line 355:              #End ExternalSource
Line 356:
Line 357:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 358:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl("&nbsp;"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"    "))
Line 359:
Line 360:              #End ExternalSource
Line 361:              Dim __ctrl5 As Global.System.Web.UI.WebControls.SqlDataSource
Line 362:
Line 363:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 364:              __ctrl5 = Me.__BuildControlSqlDataSource1
Line 365:
Line 366:              #End ExternalSource
Line 367:
Line 368:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 369:              __parser.AddParsedSubObject(__ctrl5)
Line 370:
Line 371:              #End ExternalSource
Line 372:
Line 373:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",47)
Line 374:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)))
Line 375:
Line 376:              #End ExternalSource
Line 377:              Return __ctrl
Line 378:          End Function
Line 379:
Line 380:          <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Line 381:          Private Sub __BuildControlTree(ByVal __ctrl As login_db_nav_aspx)
Line 382:
Line 383:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",1)
Line 384:              Me.InitializeCulture
Line 385:
Line 386:              #End ExternalSource
Line 387:              Dim __parser As System.Web.UI.IParserAccessor = CType(__ctrl,System.Web.UI.IParserAccessor)
Line 388:
Line 389:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",1)
Line 390:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<html>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<head>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<title>ASP.NET Login</title>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"</head>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<body>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<h2>Please L"& _
Line 391:                          "ogin:</h2>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"<p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)))
Line 392:
Line 393:              #End ExternalSource
Line 394:              Dim __ctrl1 As Global.System.Web.UI.WebControls.Label
Line 395:
Line 396:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",1)
Line 397:              __ctrl1 = Me.__BuildControllblInvalid
Line 398:
Line 399:              #End ExternalSource
Line 400:
Line 401:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",1)
Line 402:              __parser.AddParsedSubObject(__ctrl1)
Line 403:
Line 404:              #End ExternalSource
Line 405:
Line 406:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",1)
Line 407:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"</p>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)))
Line 408:
Line 409:              #End ExternalSource
Line 410:              Dim __ctrl2 As Global.System.Web.UI.HtmlControls.HtmlForm
Line 411:
Line 412:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",1)
Line 413:              __ctrl2 = Me.__BuildControl__control2
Line 414:
Line 415:              #End ExternalSource
Line 416:
Line 417:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",1)
Line 418:              __parser.AddParsedSubObject(__ctrl2)
Line 419:
Line 420:              #End ExternalSource
Line 421:
Line 422:              #ExternalSource("C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx",1)
Line 423:              __parser.AddParsedSubObject(New System.Web.UI.LiteralControl(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"</body>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"</html>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)))
Line 424:
Line 425:              #End ExternalSource
Line 426:          End Sub
Line 427:
Line 428:          <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Line 429:          Protected Overrides Sub FrameworkInitialize()
Line 430:              MyBase.FrameworkInitialize
Line 431:              Me.__BuildControlTree(Me)
Line 432:              Me.AddWrappedFileDependencies(Global.ASP.login_db_nav_aspx.__fileDependencies)
Line 433:              Me.Request.ValidateInput
Line 434:          End Sub
Line 435:
Line 436:          <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Line 437:          Public Overrides Function GetTypeHashCode() As Integer
Line 438:              Return 2057523991
Line 439:          End Function
Line 440:
Line 441:          <System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
Line 442:          Public Overrides Sub ProcessRequest(ByVal context As System.Web.HttpContext)
Line 443:              MyBase.ProcessRequest(context)
Line 444:          End Sub
Line 445:      End Class
Line 446:  End Namespace
Line 447:





--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3620; ASP.NET Version:2.0.50727.3618


Here is the error
 
Share this answer
 
Comments
Ankit Rajput 27-Apr-11 3:19am    
Have you defind this function(SqlDataSource1_Selecting' ) in your code behind or any where else
drkterror1 27-Apr-11 3:25am    
I add a SqlDatasource and configure it to connect to my login.asp
drkterror1 27-Apr-11 3:26am    
I think my problem is OleDB.. Is Oledb reliable when you are using SQLserver?
Looks like you have problem with your query string...Try like this..Just replace the below line in config file
<add name="connection" connectionstring="Server=TestSQLConnectionString; database=pubs; userID=MyUser; password=password" providername="System.Data.SqlClient" />
 
Share this answer
 
Comments
Ankit Rajput 27-Apr-11 3:18am    
this is one also will not work
Ankit Rajput 27-Apr-11 3:18am    
Server=TestSQLConnectionString; database=pubs; user ID=MyUser; password=password
drkterror1 27-Apr-11 3:28am    
Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True
Sir ive manipulated some of my codes
here is what i did:
       <br />
Using connection As New OleDbConnection("Provider=.NET Framework Data Provider for SQL Server; " _<br />
             & "Data Source=ML0003135586" & Server.MapPath("Admin") & ";")<br />
            strSQL = "SELECT * FROM [Admin] " _<br />
            & "WHERE LogName='" & Replace(txtUsername.Text, "'", "''") & "' " _<br />
            & "AND LogPass='" & Replace(txtPassword.Text, "'", "''") & "'"<br />
            myCommand = New OleDbCommand(strSQL, connection)<br />
            connection.Open()<br />
            strUserURL = myCommand.ExecuteScalar()<br />
            connection.Close()<br />


Now the problem look like this:
<br />
The '.NET Framework Data Provider for SQL Server' provider is not registered on the local machine. <br />
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. <br />
Exception Details: System.InvalidOperationException: The '.NET Framework Data Provider for SQL Server' provider is not registered on the local machine.<br />
Source Error: <br />
<br />
Line 16:             & "AND LogPass='" & Replace(txtPassword.Text, "'", "''") & "'"<br />
Line 17:             myCommand = New OleDbCommand(strSQL, connection)<br />
Line 18:             connection.Open()<br />
Line 19:             strUserURL = myCommand.ExecuteScalar()<br />
Line 20:             connection.Close()<br />
 <br />
Source File: C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx    Line: 18 <br />
Stack Trace: <br />
<br />
[InvalidOperationException: The '.NET Framework Data Provider for SQL Server' provider is not registered on the local machine.]<br />
   System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper) +963332<br />
   System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) +124<br />
   System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +86<br />
   System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +29<br />
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +4863644<br />
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117<br />
   System.Data.OleDb.OleDbConnection.Open() +40<br />
   ASP.login_db_nav_aspx.btnLogin_OnClick(Object Src, EventArgs E) in C:\Documents and Settings\oca14625\Desktop\login_db_nav.aspx:18<br />
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111<br />
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110<br />
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10<br />
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13<br />
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36<br />
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565<br />
 <br />
<br />
 
Share this answer
 
Comments
Ankit Rajput 27-Apr-11 3:47am    
Now check your connection string.
I have already mentioned the link in my Answer
Ive got it....
Thank you all for your help
<pre lang="xml"><%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Web.UI" %>

<script language="VB" runat="server">

    Sub btnLogin_OnClick(Src As Object, E As EventArgs)
        Dim strSQL As String
        Dim strUserURL As String
        Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection("Data Source=ML0003135586;Integrated Security=SSPI;" & "Initial Catalog=TestSQL")
        strSQL = "SELECT * FROM [tblLog] " _
        & "WHERE LogName='" & Replace(txtUsername.Text, "'", "''") & "' " _
        & "AND LogPass='" & Replace(txtPassword.Text, "'", "''") & "'"
        connection.Open()
        Dim myCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQL, connection)
        strUserURL = myCommand.ExecuteScalar()

        If strUserURL <> "" Then
            lblInvalid.Text = ""
            FormsAuthentication.SetAuthCookie(txtUsername.Text, True)
            Response.Redirect("bob.aspx")
        Else
            lblInvalid.Text = "Sorry... try again..."
        End If


    End Sub
    '("Data Source=ML0003135586;Integrated Security=SSPI;" & "Initial Catalog=TestSQL")
    'Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True
</script>

<html>
<head>
<title>ASP.NET Login</title>
</head>
<body>

<h2>Please Login:</h2>

<p>
<asp:Label id="lblInvalid" runat="server" />
</p>

<form id="Form1" runat="server">

    Username: <asp:TextBox id="txtUsername" runat="server" /><br />
    Password: <asp:TextBox id="txtPassword" TextMode="password" runat="server" Width="155px" /><br />
    <br />
    position: &nbsp;&nbsp;
    <asp:TextBox id="items" runat="server" /><br />
    <br />
    <br />
    <asp:Button id="btnLogin" runat="server"
        text="Login" OnClick="btnLogin_OnClick" Width="221px"
    />&nbsp;&nbsp;
</form>


</body>
</html>

 
Share this answer
 
please send sql connectivity example in asp .net
 
Share this answer
 
TRY THIS

XML
<pre lang="xml"><%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Web.UI" %>

<script language="VB" runat="server">

    Sub btnLogin_OnClick(Src As Object, E As EventArgs)
        Dim strSQL As String
        Dim strUserURL As String
        Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection("Data Source=ML0003135586;Integrated Security=SSPI;" & "Initial Catalog=TestSQL")
        strSQL = "SELECT * FROM [tblLog] " _
        & "WHERE LogName='" & Replace(txtUsername.Text, "'", "''") & "' " _
        & "AND LogPass='" & Replace(txtPassword.Text, "'", "''") & "'"
        connection.Open()
        Dim myCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQL, connection)
        strUserURL = myCommand.ExecuteScalar()

        If strUserURL <> "" Then
            lblInvalid.Text = ""
            FormsAuthentication.SetAuthCookie(txtUsername.Text, True)
            Response.Redirect("bob.aspx")
        Else
            lblInvalid.Text = "Sorry... try again..."
        End If


    End Sub
    '("Data Source=ML0003135586;Integrated Security=SSPI;" & "Initial Catalog=TestSQL")
    'Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True
</script>

<html>
<head>
<title>ASP.NET Login</title>
</head>
<body>

<h2>Please Login:</h2>

<p>
<asp:Label id="lblInvalid" runat="server" />
</p>

<form id="Form1" runat="server">

    Username: <asp:TextBox id="txtUsername" runat="server" /><br />
    Password: <asp:TextBox id="txtPassword" TextMode="password" runat="server" Width="155px" /><br />
    <br />
    position:
    <asp:TextBox id="items" runat="server" /><br />
    <br />
    <br />
    <asp:Button id="btnLogin" runat="server"
        text="Login" OnClick="btnLogin_OnClick" Width="221px"
    />
</form>


</body>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900