String check = Data.Logins.Where(Login=>Login.Username==TextBoxnewusername.Text)
I have a table named "Login".
There are 4 columns - Username, password, Name, Address.
The Username column is of data type nvarchar(max).
The 'TextBoxnewusername.Text' is a textbox where new users input their user name.
Now, the error is as follows-
Cannot implicitly convert type 'system.linq.IQueryable' to 'String'.
Any idea how to correct it?? Is there any casting it?

Nigel FernandesRank #753 · 3.1K reputationPosted Aug 6, 2017, 4:40 PM EDT
Gnanavel SekarRank #333 · 7.5K reputationPosted Aug 6, 2017, 5:43 PM EDT
Rijwan AnsariRank #82 · 24.2K reputationPosted Aug 8, 2017, 8:13 AM EDT
Sayan Chatterjee22 reputationPosted Aug 9, 2017, 7:01 AM EDT
{
using (ShopDataContext Data = new ShopDataContext())
{
Login newlogin = new Login(); //Creating instance of the 'Login' table//
var check = Data.Logins.Where(Login => Login.Username==TextBoxnewusername.Text); //Lambda expression//
foreach (Login output in check)
{
if (output.Username != TextBoxnewusername.Text)
{
newlogin.Name = TextBoxname.Text;
newlogin.Username = TextBoxnewusername.Text;
newlogin.Address = TextBoxaddress.Text;
newlogin.password = TextBoxnewpassword.Text;
Data.Logins.InsertOnSubmit(newlogin);
Data.SubmitChanges();
Labelmessage.Text = "Successful";
}
else
{
Labelmessage.Text = "User name already exists in the database, pls. select a new username";
}
}
}
}
D DonthuRank #2,299 · 614 reputationPosted Aug 6, 2017, 9:38 AM EDT
Rajkiran SwainRank #165 · 14.4K reputationPosted Aug 8, 2017, 8:48 AM EDT