Hej jag får följande felmeddelande på koden i visual studio nedan när jag ska logga in trots att jag tidigare har skapat en användare. Jag förstår inte vad som menas. //BoFelmeddelande vid inlogg
Felmeddelande: Format of the initialization string does not conform to specification starting at index 0.
När jag googlat felmeddelandet verkar flera vara inne på fel i connectionString, men jag kan inte se något fel. Det fungerar när jag ska lägga till nya användare.
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="BosseUnited" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|BosseDatabase.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<authentication mode="Forms">
<forms name="Bosse" loginUrl="login.aspx" path="/" />
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
</system.web>
</configuration>
Username: <asp:TextBox ID="Textbox1" runat="server">
</asp:TextBox><br />
Password: <asp:TextBox ID="Textbox2" TextMode="Password" runat="server">
</asp:TextBox><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
Imports System.Data
Imports System.Data.SqlClient
Public Class login
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim cmdString As String = "SELECT [Password] FROM [aspnet_Users] WHERE ([Username] = @UserName) AND ([Password] = @Password)"
conn = New SqlConnection("BosseUnited")
cmd = New SqlCommand(cmdString, conn)
cmd.Parameters.Add("@Username", SqlDbType.VarChar, 50)
cmd.Parameters("@Username").Value = Textbox1.Text
cmd.Parameters.Add("@Password", SqlDbType.VarChar, 50)
cmd.Parameters("@Password").Value = Textbox2.Text
conn.Open()
Dim myReader As SqlDataReader
myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
If myReader.Read() Then
FormsAuthentication.RedirectFromLoginPage(Textbox1.Text, False)
Else
Response.Write("Invalid credentials")
End If
myReader.Close()
End Sub
End Class