goo.gl/RFY5C2 : Subscribe to CodAffection goo.gl/Z6SkSC : C# CRUD Operations With DB goo.gl/WsgPbp : C# User Registration With DB goo.gl/Gu5q37 : Export PDF in C#
In stead of saving the file, click the UPDATE button in the top left cornor of the window, then you'll get a window where you can click execute query, your table will be added to your database ;)
Hi, I have a question. In video, you have one main form. But if I have two, and for each form I have login and password, how I can realize this? 9:10 - I see, you create here 2 users, but you didn't use 2nd user in code. I try did it - I remade part of code "if(dtbl.Rows.Count == 1)", where I changed 1 to 2 and changed text in braces for my 2nd form and this reworked part I inserted after "else {...}". But when I run the application and enter the data for the second user, Visual Studio opens for some reason the first form. What should I do?
OMG! You saved me! Thought I was going to be up all night again trying to finish my project, but this video was SOOO helpful! Thank you, thank you, thank you.
At 8:40 when i press ctl+s instead of showing a dialoge box that shows in the video like choose name, my PC asks to saves the file in my documents or in local disk drive instead of saving it in visual studio like a dialoge box has appeared for the name of the table. Please can someone help. Please.
I think i have the same problem too. I first save a place where in your drive then in the upper-left corner of the Table Designer, select the Update button. Then you save it I think(because im trying
System.Data.SqlClient.SqlException (0x80131904): An attempt to attach an auto-named database for file C: \Users\jmpla\source epos\Aqua Lab\DataBase\LoginDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. HELPPP
Thanks for this tutorial , but I have a problem with the sda.Fill(dtbl). ==> System.Data.SqlClient.SqlException: 'An expression of non-boolean type specified in a context where a condition is expected, near 'de'.' I have already read the comments and i didn't find the right answer . Please answer me as soon as possible.
Those having issue with sda.Fill(dt); please, check your sda query, the username and password we are using from input in the query should have apostrophes " ' " enclosing them. please, check the code carefully and make sure you add those, and your problem will be solved.
I cant debug it shows 1)The name 'txtusername' does not exist in the current context 2)The name 'txtpassword' does not exist in the current context Plz help what I do
Don't know if you figured it out or not but I will leave this here for anyone with the same problem. There is an update button at the top of the table you can click on. It will then save it on the existing mdf file. Under the table there is a sql query on that you can edit your table. Make changes here. To see the change or whether your table is created or not you have to rightclick the table folder on the database connection and refresh.
Showing how to save the table Press Ctrl + S to Save the Table. it will open a dialog box, Name your table inside the dialog box, then click OK. Then added sample record into the table.
Thank you for good subject guven for me....i have an doubt I. E., u r creating one table that is login table in database right, in that table first username value is 1 only....y u giving user1 as in username value in login form? 1 and user1 both r same in this situation? Please clarify my doubt as soon as possible. I'm waiting for ur response. Tq
System.Data.SqlClient.SqlException: 'An attempt to attach an auto-named database for file C: \Users\sam\Desktop\Passwords And user.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.'
bakit kapag pinipindot ko yung login ganto nalabas? An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll Additional information: An attempt to attach an auto-named database for file C: \Users\Mercado\Documents\Visual Studio 2015\Projects\GenericoCashieringSystem\GenericoCashieringSystem\LoginDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Why this error occur at 'sda.Fill(dtbl)'? Exception unhandled System.Data.SqlClient.SqlException: 'An attempt to attach an auto-named database for file C: \Users\User\Documents\Visual Studio 2017\Projects\LoginApp\DB\LoginDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.'
How to make it to connect to a website Sql data have I replaced the like url for the database with the remote database but when I hit start it will stop saying like it can't connect but it's connected in visual studio.
Iam using vs 2017 but when i ctrl + s to name the table it doesnt open any dialog box and takes me to save it and not showing it in tables ? Can you help me out
I wrote my code exactly like this, only my table name is /*Signup*/. Upon running the application even after entering correct username and password it is saying check username and password. Please help
A network related or instance specific error occured while establishing a connection to sql server. the server was no found or was not accessible. verify that the instance name is correct and that sql server is configured to allow remote connections. proivder sql network interfaces, error 26 error locating server/. instance specified I'm getting this problem in adding connection can you help me?
can you help me i want to make my button to add number on text box example if i click the button there will be value in text box EXAMPLE: clicked the button textbox value = 1 clicked the button for the second time the value of textbox 1 will be 2 and so on
how can i fix Error 1 An object reference is required for the non-static field, method, or property 'System.Windows.Forms.Control.Show()' c:\users eda\documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs 33 16 WindowsFormsApplication1
but the password string anyone can see if they open sql server database. How can convert the password string into some unique symbol in sql server that is not the password we type in the text box?
he when i save the table it ask where i wanna save it then it isnt coming up in the table column i have refreshed and it still isnt there if you can help it would be appreciated greatly
To see newly created table under tables you may need to refresh to save table Press ctrl + S Or Press Save Icon from top left corner it will show a pop up dialogue box - enter table name Click Ok that is it
Hi, I'm using VS 2017. Thank you for this video, it is great and so helpful! But I followed exactly as what you have shown but when I entered the right credentials, it will run the else statement still. Do you know how I can fix this? Thank you in advance~!
The same. try "string query = "Select * from [Table] Where username = '" +textBox1.Text.Trim()..." my table name is "Table", when I add "[]" everything is ok :)
and how do you fix this?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ty :)
@Dotnet Mob Hello i need help ! Every time i press login this shows up : Unhandled exception has occurred in your application...... Incorrect syntax near the keyword 'Table' pls help fast cuz i need 2 finish this project in 3 weaks and your tutorials helped me so far
@@CodAffection Hi i have the same problem, my login table is just called Table, also im using VS 2017, The Error... System.Data.SqlClient.SqlException HResult=0x80131904 Message=Incorrect syntax near the keyword 'Table'. Source=.Net SqlClient Data Provider StackTrace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) at WindowsFormsApp6.loginFrm.loginBtn_Click(Object sender, EventArgs e) in C:\Users\Gary\source epos\WindowsFormsApp6\WindowsFormsApp6\Form1.cs:line 28 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at WindowsFormsApp6.Program.Main() in C:\Users\User\source epos\WindowsFormsApp6\WindowsFormsApp6\Program.cs:line 19 My Code... SqlConnection sqlcon = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\User\source epos\WindowsFormsApp6\WindowsFormsApp6\Database\LoginData.mdf;Integrated Security=True;Connect Timeout=30"); string query = "Select * From Table where username ='" + usernameTxt.Text.Trim() + "' and password = '" + passwordTxt.Text.Trim() + "'"; SqlDataAdapter sda = new SqlDataAdapter(query, sqlcon); DataTable dtbl = new DataTable(); sda.Fill(dtbl); if (dtbl.Rows.Count > 0 && dtbl.Rows[0][0].ToString().Equals("1")); { mainFrm objMainFrm = new mainFrm(); this.Hide(); objMainFrm.Show(); } Thanks for the video i really needed this.
I know others have asked, but i cant see the replies. I have an error on the sda.Fill(dtbl), I'm told "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)" Any tips on how to fix this?
Getting this error Plzz Help??? Error 1 The type or namespace name 'frmMain' could not be found (are you missing a using directive or an assembly reference?
goo.gl/RFY5C2 : Subscribe to CodAffection
goo.gl/Z6SkSC : C# CRUD Operations With DB
goo.gl/WsgPbp : C# User Registration With DB
goo.gl/Gu5q37 : Export PDF in C#
I am beginner to C#. Search many places. But your explained the working method step by step. Thanks a lot.
Glad to hear that
please help I am at 17:50, and I get this error no matter what
System.Data.SqlClient.SqlException: 'Incorrect syntax near the keyword 'Table'.'
Same
Can you help me? At the saving 8:45 if I click OK at save in into DB it doesnt show in server explorer at tables
In stead of saving the file, click the UPDATE button in the top left cornor of the window, then you'll get a window where you can click execute query, your table will be added to your database ;)
Hi, I have a question. In video, you have one main form. But if I have two, and for each form I have login and password, how I can realize this?
9:10 - I see, you create here 2 users, but you didn't use 2nd user in code. I try did it - I remade part of code "if(dtbl.Rows.Count == 1)", where I changed 1 to 2 and changed text in braces for my 2nd form and this reworked part I inserted after "else {...}". But when I run the application and enter the data for the second user, Visual Studio opens for some reason the first form. What should I do?
OMG! You saved me! Thought I was going to be up all night again trying to finish my project, but this video was SOOO helpful! Thank you, thank you, thank you.
did u finish it?
@@ishkasewshanker3813 we hope so
even after 4 years it`s a best video. thx man
Thanks man i have windows app interview today thanks a lot
Tried this for a project i am building, very helpful Thank you. You should upload some recent videos like this of Visual Studio 2019
This helped me a lot😊thank youw❤
Great tutorial, Thank you.
At 8:40 when i press ctl+s instead of showing a dialoge box that shows in the video like choose name,
my PC asks to saves the file in my documents or in local disk drive instead of saving it in visual studio like a dialoge box has appeared for the name of the table. Please can someone help. Please.
I think i have the same problem too. I first save a place where in your drive then in the upper-left corner of the Table Designer, select the Update button.
Then you save it I think(because im trying
System.Data.SqlClient.SqlException (0x80131904): An attempt to attach an auto-named database for file C: \Users\jmpla\source
epos\Aqua Lab\DataBase\LoginDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. HELPPP
Crystal clear! Thanks a lot.
Best tutorial so far for login authentication..
I am glad you found the video helpful.
Thank you very much, it worked perfectly!
I'm glad it helped.
Thank you sir! Very good tutorial.
Thanks for this tutorial , but I have a problem with the sda.Fill(dtbl).
==> System.Data.SqlClient.SqlException: 'An expression of non-boolean type specified in a context where a condition is expected, near 'de'.'
I have already read the comments and i didn't find the right answer .
Please answer me as soon as possible.
im stuck there aswell, hope u found an answer after a year xD
7:58 when i clicked new table an error occured called : "An incompatible SQL server version was detected "
What should i do man?
Have you tried this : stackoverflow.com/a/27881800/4133590
Thanks for the help, it worked🎉
Those having issue with sda.Fill(dt);
please, check your sda query, the username and password we are using from input in the query should have apostrophes " ' " enclosing them. please, check the code carefully and make sure you add those, and your problem will be solved.
thanks for the info . hope you found this C# tutorial helpful.
@@CodAffection yes sir, your turorial has helped me a lot. Thank you so much !
Crystal clear. Thanks for the explanation, it really helped!
Your are the Best mate! straightforward and easy to follow the steps, Thanks...
you are welcome, by the way thanks for watching my video
thankyou you just saved my life
Thank you very much! My software buyers can now safely use their purchased program!
glad you found the video helpful in your live projects.
What a load lol, if anyone was buying software it wouldnt be from someone who couldnt make a login form.
Thanks! Its working :D
Thank you.!
Super gooooood!!! Thank you!)))
thank you so much! ❤
I cant debug it shows 1)The name 'txtusername' does not exist in the current context
2)The name 'txtpassword' does not exist in the current context
Plz help what I do
same thing(((
I"m using Visual studio 2019. I cannot create tables with the steps provided by you. In the Server Explorer under the table it shows nothing.
Don't know if you figured it out or not but I will leave this here for anyone with the same problem. There is an update button at the top of the table you can click on. It will then save it on the existing mdf file. Under the table there is a sql query on that you can edit your table. Make changes here. To see the change or whether your table is created or not you have to rightclick the table folder on the database connection and refresh.
@@hackslash834 ya i fixed the issue thanks for the comment.
thanks for sharing your thoughts.
Use secure procedure is better than leaving open SQL query string
8:36 could you explain what do you say there?
Showing how to save the table
Press Ctrl + S to Save the Table. it will open a dialog box, Name your table inside the dialog box, then click OK.
Then added sample record into the table.
Thank you for fast answer. I appreciate all work that you put into your videos. It is very helpful. Thank you! :)
Thanks Lot very helpful keep it up !!!
Thank you for good subject guven for me....i have an doubt I. E., u r creating one table that is login table in database right, in that table first username value is 1 only....y u giving user1 as in username value in login form? 1 and user1 both r same in this situation? Please clarify my doubt as soon as possible. I'm waiting for ur response. Tq
sorry, I didn't get you.
System.Data.SqlClient.SqlException: 'An attempt to attach an auto-named database for file C: \Users\sam\Desktop\Passwords And user.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.'
try this stackoverflow.com/a/14779107/4133590
Bro much love for you you helped me a lot i loveyou so much have a great life
thanks for the wonderful comment.
This was pretty helpful. Thanks a mill
bakit kapag pinipindot ko yung login ganto nalabas?
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: An attempt to attach an auto-named database for file C: \Users\Mercado\Documents\Visual Studio 2015\Projects\GenericoCashieringSystem\GenericoCashieringSystem\LoginDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
*YOU ARE THE BEST!!!*
Thank You Sir....!!!!
Thanks alot man, very useful!!
:)
Thank you very much for this.
this helped me thank you bro
I love u man, thank u :)
You helped me a lot. Thank you!
you are welcome.
query one record then direct to main form to open but not to match successfully with bool true.
god bless you and your voice
sir! thank you!its works fine!
Thank you For helping Others!!!!!!
how can i display the name of the user who logged in to the next form?
you need the database varible and in textlabel script
label.text = "varible"
Why this error occur at 'sda.Fill(dtbl)'?
Exception unhandled
System.Data.SqlClient.SqlException: 'An attempt to attach an auto-named database for file C: \Users\User\Documents\Visual Studio 2017\Projects\LoginApp\DB\LoginDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.'
did you download the source code ?
Yes... can you teach me how to enter RC4 encryption for the password?
Thanks a lot❤️❤️❤️❤️
The name 'ObjFrmMain' not exist at the current context. could you help me please?
very useful thanks a lot
How to make it to connect to a website Sql data have I replaced the like url for the database with the remote database but when I hit start it will stop saying like it can't connect but it's connected in visual studio.
you want to connect Live SQL Server Database ?
😍😇 thnk U sO mUch sir !!
Iam using vs 2017 but when i ctrl + s to name the table it doesnt open any dialog box and takes me to save it and not showing it in tables ?
Can you help me out
same thing happens to me
You may try to save it under the db location and refresh table
Thank you it has Great tutorial
Server Explore in Data Connections in LoginDB in Table in File do not show.
Please sir Help me
same
When I add table n databse it doesnot appear in table option.
I wrote my code exactly like this, only my table name is /*Signup*/. Upon running the application even after entering correct username and password it is saying check username and password. Please help
nice uploade more video related windows form
How to create it for multi user so every one has different form apperead after logging in??
is that possible when i click login it navigate to my google account?
when I hit add a table it just says loading... the design surface is loading.. it's been 27 minutes ffs
A network related or instance specific error occured while establishing a connection to sql server. the server was no found or was not accessible. verify that the instance name is correct and that sql server is configured to allow remote connections. proivder sql network interfaces, error 26 error locating server/. instance specified
I'm getting this problem in adding connection can you help me?
please SQL server connection string.
Already fix this thank you i just downloaded the sql server
can you help me i want to make my button to add number on text box example if i click the button there will be value in text box
EXAMPLE: clicked the button textbox value = 1
clicked the button for the second time the value of textbox 1 will be 2 and so on
If Textbox = txt , Button = btn, (Control Naming)
txt.Text =(Convert.ToInt32(txt .Text)+ 1).ToString();
Dear I got error ' invalid object name ' ? Please help me..
The type or namespace name 'Form2' could not be found how do i fix this in my form? only "Form1" works but not "Form2"
Thank you so much very helpful :-)
thanks for the comment.
how can i fix
Error 1 An object reference is required for the non-static field, method, or property 'System.Windows.Forms.Control.Show()' c:\users
eda\documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs 33 16 WindowsFormsApplication1
the frmMain is not colored , what should i do ?
Hi sir I have some problem when I write the correct username and password its show not correct I don't know why
can you help me please?
sda.fill(dtbl); is causing an error where it cannot find the file do you have any idea what might be wrong?
ping me at askdotnetmob@gmail.com.
it is necessary to any sql database is install in my laptop ?
it's not necessary, you can access sql server from other connected systems also.
but the password string anyone can see if they open sql server database. How can convert the password string into some unique symbol in sql server that is not the password we type in the text box?
Thank you
thanks a million bro.
thank you very very mutch
God Bless You
he when i save the table it ask where i wanna save it then it isnt coming up in the table column i have refreshed and it still isnt there if you can help it would be appreciated greatly
To see newly created table under tables you may need to refresh
to save table Press ctrl + S Or Press Save Icon from top left corner
it will show a pop up dialogue box - enter table name Click Ok that is it
do you still have the "Do not delete" folder in C:/ drive? :p
no, now it 'can be deleted'.
the fill function does not work like that it say a missing .. the error message says that the server was not found or was not accessible
please verify your connection string.
this still works until now :D
Hi, I'm using VS 2017. Thank you for this video, it is great and so helpful! But I followed exactly as what you have shown but when I entered the right credentials, it will run the else statement still. Do you know how I can fix this? Thank you in advance~!
did you check with break points?
CodAffection sorry, but how do I do that?
th-cam.com/video/FKAOHtxiloA/w-d-xo.html
Sir you are the best
My Pleasure, Happy Coding
It works, Thank you
Thank you so much for the Code it will help me for life time
Glad you found the video helpful.
@@CodAffectionth-cam.com/video/VuAblmhisxc/w-d-xo.html
Great. Thanks so much :D
you are welcome
ive got a problem with the sda.Fill(dtbl); line
please check connection string and stored procedure.
The same. try "string query = "Select * from [Table] Where username = '" +textBox1.Text.Trim()..." my table name is "Table", when I add "[]" everything is ok :)
@@dorotauszok9716 and me do you fix?
i have the problem on sda.Fill(dtbl); , how to solve this problem
Has anyone found the solution to this problem if so please reply asap
you dont have a conection in your form 2
and how do you fix this?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ty :)
@@scrub2657 Please check db connection string and query string.
If nothing works leave a message in fb page. let me check what I can do.
@@CodAffection everything is fine. Just,
sda.Fill(dtb1);
is error
@Dotnet Mob Hello i need help ! Every time i press login this shows up : Unhandled exception has occurred in your application...... Incorrect syntax near the keyword 'Table' pls help fast cuz i need 2 finish this project in 3 weaks and your tutorials helped me so far
Let me see your query for login operation.
@@CodAffection Hi i have the same problem, my login table is just called Table, also im using VS 2017,
The Error...
System.Data.SqlClient.SqlException
HResult=0x80131904
Message=Incorrect syntax near the keyword 'Table'.
Source=.Net SqlClient Data Provider
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at WindowsFormsApp6.loginFrm.loginBtn_Click(Object sender, EventArgs e) in C:\Users\Gary\source
epos\WindowsFormsApp6\WindowsFormsApp6\Form1.cs:line 28
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsFormsApp6.Program.Main() in C:\Users\User\source
epos\WindowsFormsApp6\WindowsFormsApp6\Program.cs:line 19
My Code...
SqlConnection sqlcon = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\User\source
epos\WindowsFormsApp6\WindowsFormsApp6\Database\LoginData.mdf;Integrated Security=True;Connect Timeout=30");
string query = "Select * From Table where username ='" + usernameTxt.Text.Trim() + "' and password = '" + passwordTxt.Text.Trim() + "'";
SqlDataAdapter sda = new SqlDataAdapter(query, sqlcon);
DataTable dtbl = new DataTable();
sda.Fill(dtbl);
if (dtbl.Rows.Count > 0 && dtbl.Rows[0][0].ToString().Equals("1"));
{
mainFrm objMainFrm = new mainFrm();
this.Hide();
objMainFrm.Show();
}
Thanks for the video i really needed this.
I am not able to use datable for some reason. I type dataTable and throws error
could you elaborate the actual issue in detail ?
nice tutorial
Very nice person
why you cannot write string query into sql adapter ??? because thats an easy method ...
stored procedures are pre-compiled, so better performance than string query.
'System.Data.SqlClient.SqlException' occurred in System.Data.dll what this error when i try i get it
Check Connection String Inside 'new SqlConnection(@"");'
it my sda.fill(dt) that coming out this error
i have the same error...
I know others have asked, but i cant see the replies. I have an error on the sda.Fill(dtbl), I'm told "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)" Any tips on how to fix this?
ping me at askdotnetmob@gmail.com with possible screen shots.
Dotnet Mob thank you but I figured it out. Daft mistake on my part 😂😂 thanks for the tutorial. Subbed.
@Abigail Partis i got the same error can u help me ??
please check your connection string.
Main Menu - the window which opens after corrrect login. After closing Main Menu window the program doesn't close(
thanks for this video bro
Getting this error Plzz Help???
Error 1 The type or namespace name 'frmMain' could not be found (are you missing a using directive or an assembly reference?
Name your actual form 'frmMain'