开发者

The Keyword Used is Not Supported (MySQL and Visual Studio 2010)

I am creating a login form using C# and MySQL. I got stuck in SQLConnection. It says that the keyword I used is not supported.

This is my code:

        using (var con = new SqlConnection("host=localhost;us开发者_高级运维r=root;password=admin;db=timekeeping;"))
        using (var cmd = con.CreateCommand())
        {
            con.Open();
            cmd.CommandText = "SELECT count(*) FROM receptionist WHERE username = @username AND password = @password;";
            cmd.Parameters.AddWithValue("@username", username);
            cmd.Parameters.AddWithValue("@password", password);
            var count = (long)cmd.ExecuteScalar();
            return count > 0;
        }

This is the screenshot of the error message:

The Keyword Used is Not Supported (MySQL and Visual Studio 2010)


You need to use the correct connection string keywords for MySQL:

From Connectionstrings.com:

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;


Please change your connection string from

"host=localhost;usr=root;password=admin;db=timekeeping;" 

to

"Server=127.0.0.1;Database=timekeeping;Uid=root;password=admin"  

Hopefully it will work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜