Click here to Skip to main content
14,430,233 members
   

C#

 
GeneralRe: how to check if value exists in database from textbox c# Pin
F-ES Sitecore26-Nov-19 6:11
mveF-ES Sitecore26-Nov-19 6:11 
GeneralRe: how to check if value exists in database from textbox c# Pin
Pete O'Hanlon27-Nov-19 0:23
communityengineerPete O'Hanlon27-Nov-19 0:23 
AnswerRe: how to check if value exists in database from textbox c# Pin
Richard MacCutchan25-Nov-19 4:39
communityengineerRichard MacCutchan25-Nov-19 4:39 
AnswerRe: how to check if value exists in database from textbox c# Pin
OriginalGriff25-Nov-19 4:52
communityengineerOriginalGriff25-Nov-19 4:52 
AnswerRe: how to check if value exists in database from textbox c# Pin
#realJSOP25-Nov-19 10:23
mva#realJSOP25-Nov-19 10:23 
AnswerRe: how to check if value exists in database from textbox c# Pin
hailu worku26-Nov-19 3:59
Memberhailu worku26-Nov-19 3:59 
GeneralRe: how to check if value exists in database from textbox c# Pin
Pete O'Hanlon26-Nov-19 4:28
communityengineerPete O'Hanlon26-Nov-19 4:28 
SuggestionRe: how to check if value exists in database from textbox c# Pin
Eddy Vluggen26-Nov-19 7:15
professionalEddy Vluggen26-Nov-19 7:15 
Pete O'Hanlon wrote:
And what happens if the database is not SQL Server? What if the textbox is an ASP.NET Core one? You are making a lot of assumptions with your answer.
Same can be said from OG's answer, which I still find very valuable.

The assumption for SQL Server is a valid one; if it is another database a similar technique is used and the example given remains valid with minimal change.

I'd argue that it should program against the interface, and use the CreateCommand method from the connection, taking the value of the textbox as an argument.

using (SqlConnection con = new SqlConnection(strConnect))
using (IDbCommand cmd = con.CreateCommand())
{
   cmd.CommandText = "bla"; 
   con.Open(); // as late as possible
And yes, even that would be improved by using the DBProviderFactory, getting the connectionstring and provider from the Settings.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

AnswerRe: how to check if value exists in database from textbox c# Pin
#realJSOP27-Nov-19 1:55
mva#realJSOP27-Nov-19 1:55 
AnswerRe: how to check if value exists in database from textbox c# Pin
Gerry Schmitz27-Nov-19 8:15
mveGerry Schmitz27-Nov-19 8:15 
AnswerRe: how to check if value exists in database from textbox c# Pin
Shraddha_Patel16-Dec-19 23:30
MemberShraddha_Patel16-Dec-19 23:30 
AnswerRe: how to check if value exists in database from textbox c# Pin
Roland Skeyhill13hrs 16mins ago
MemberRoland Skeyhill13hrs 16mins ago 
Questionplotting a point graph for a continuous real time data in c# windows form application Pin
Member 1465244924-Nov-19 23:48
MemberMember 1465244924-Nov-19 23:48 
QuestionRe: plotting a point graph for a continuous real time data in c# windows form application Pin
Richard MacCutchan25-Nov-19 0:16
communityengineerRichard MacCutchan25-Nov-19 0:16 
AnswerRe: plotting a point graph for a continuous real time data in c# windows form application Pin
Member 1465244925-Nov-19 1:28
MemberMember 1465244925-Nov-19 1:28 
GeneralRe: plotting a point graph for a continuous real time data in c# windows form application Pin
Richard MacCutchan25-Nov-19 2:04
communityengineerRichard MacCutchan25-Nov-19 2:04 
QuestionNeed Help With Syntax Pin
Kevin Marois23-Nov-19 11:01
professionalKevin Marois23-Nov-19 11:01 
AnswerRe: Need Help With Syntax Pin
phil.o23-Nov-19 11:25
mvephil.o23-Nov-19 11:25 
GeneralRe: Need Help With Syntax Pin
Kevin Marois23-Nov-19 11:40
professionalKevin Marois23-Nov-19 11:40 
GeneralRe: Need Help With Syntax Pin
Kevin Marois23-Nov-19 11:58
professionalKevin Marois23-Nov-19 11:58 
GeneralRe: Need Help With Syntax Pin
phil.o23-Nov-19 12:29
mvephil.o23-Nov-19 12:29 
RantRe: Need Help With Syntax Pin
Kevin Marois23-Nov-19 13:26
professionalKevin Marois23-Nov-19 13:26 
GeneralRe: Need Help With Syntax Pin
phil.o23-Nov-19 13:45
mvephil.o23-Nov-19 13:45 
QuestionDeleting textbox created dynamically, using delete key, while there are more than 1 textbox that have been dragged and dropped on a picture box. Pin
Member 443266022-Nov-19 2:14
MemberMember 443266022-Nov-19 2:14 
AnswerRe: Deleting textbox created dynamically, using delete key, while there are more than 1 textbox that have been dragged and dropped on a picture box. Pin
OriginalGriff22-Nov-19 2:31
communityengineerOriginalGriff22-Nov-19 2:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.