Witam
Mam o to taki problem. W swojej aplikacji podczas próby logowania dostaje błąd "nieprawidłowy format ciągu wejściowego".
Zmieniałem już opcje regionalne ale to nie skutkuje kod wygląda tak
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Globalization;
namespace Library
{
public partial class logowanie : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button5_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString);
con.Open();
string checkuser = "select email, haslo from uzytkownicy where email= '" + TextBoxlogin.Text + "'";
SqlCommand com = new SqlCommand(checkuser, con);
string currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
CultureInfo ci = new CultureInfo(currentCulture);
//Ustawiamy nowy format
ci.NumberFormat.NumberDecimalSeparator = ".";
System.Threading.Thread.CurrentThread.CurrentCulture = ci;
int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
con.Close();
if (temp == 1)
{
con.Open();
string checkPasswordQuery = "Select haslo, email from uzytkownicy where email='" + TextBoxlogin.Text + "'";
SqlCommand passcom = new SqlCommand(checkPasswordQuery, con);
string haslo = passcom.ExecuteScalar().ToString();
if (haslo == TextBoxhaslo.Text)
{
Session["New"] = TextBoxlogin.Text;
Response.Redirect("panel uzytkownika.aspx");
}
else
{
Response.Write("haslo nie jest git");
}
}
else
{
Response.Write("login nie jest git");
}
}
private void Replace(string p1, string p2)
{
throw new NotImplementedException();
}
private void Replace()
{
throw new NotImplementedException();
}
}
}
W miejsce int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
wstawiałem
int temp = Convert.ToInt32(com.ExecuteScalar().ToString().Replace(",","."));
ale to też nic nie działa. Proszę o jakąś radę