C# Application - Insert Delete Update Select in SQL Server | FoxLearn

C# Application - Insert Delete Update Select in SQL Server | FoxLearn

Fox Learn

8 лет назад

183,283 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Gene Gabriel Ramirez
Gene Gabriel Ramirez - 07.10.2022 08:45

is there a difference if I use it windows authorized?

Ответить
Betsy Beam
Betsy Beam - 29.03.2022 08:44

So helpful! Any chance you could send me the source code? I'm stuck on the entity part but trying to solve it myself.

Ответить
George Samuel
George Samuel - 11.04.2021 18:44

Is there a difference between the local database and SQL server?

Ответить
Azrail
Azrail - 28.03.2021 13:17

I have created a similiar to yours but with sqlite, but I need to add a search button where user passes a text and get the row based on the text in the datagrid ( or even a combobox that chooses category and searches in that category ) . You have some tutorials on search but you don't use entity or dapper in those.

Ответить
Dosjan AZ
Dosjan AZ - 29.09.2020 08:28

great )

Ответить
Bongisizwe Mali
Bongisizwe Mali - 03.07.2020 01:46

This is great. Can you please send me the code. [[email protected]]

Ответить
Tom D
Tom D - 25.06.2020 16:13

namespace CRUDSqlServer
{
public partial class Form1 : Form
{
TestEntities test;
public Form1()
{
InitializeComponent();
}

private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{

}

private void btnNew_Click(object sender, EventArgs e)
{
try
{
panel.Enabled = true;
txtCustomerID.Focus();
Customer c = new Customer();
test.Customers.Add(c);
customerBindingSource.Add(c);
customerBindingSource.MoveLast();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private void btnEdit_Click(object sender, EventArgs e)
{
panel.Enabled = true;
txtCustomerID.Focus();
}

private void btnCancel_Click(object sender, EventArgs e)
{
panel.Enabled = false;
customerBindingSource.ResetBindings(false);
foreach (DbEntityEntry entry in test.ChangeTracker.Entries())
{
switch (entry.State)
{
case EntityState.Added:
entry.State = EntityState.Detached;
break;
case EntityState.Modified:
entry.State = EntityState.Unchanged;
break;
case EntityState.Deleted:
entry.Reload();
break;
}
}

}

private void btnSave_Click(object sender, EventArgs e)
{
try
{
customerBindingSource.EndEdit();
test.SaveChangesAsync();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
customerBindingSource.ResetBindings(false);
}
}

private void Form1_Load(object sender, EventArgs e)
{
panel.Enabled = false;
test = new TestEntities();
customerBindingSource.DataSource = test.Customers.ToList();
}

private void txtSearch_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
if (string.IsNullOrEmpty(txtSearch.Text))
{
dataGridView.DataSource = customerBindingSource;
}
else
{
var query = from o in customerBindingSource.DataSource as List<Customer>
where o.CustomerID == txtSearch.Text || o.Fullname.Contains(txtSearch.Text) || o.Email.Contains(txtSearch.Text) || o.Address.Contains(txtSearch.Text)
select o;

dataGridView.DataSource = query.ToList();
}
}
}

private void dataGridView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
if (MessageBox.Show("Are you sure you want to delete this record", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
{
customerBindingSource.RemoveCurrent();
}
}

}
}
}

Ответить
Razi Ahmad
Razi Ahmad - 03.04.2020 10:26

Awesome 👍

Ответить
İbrahim Koyuncu
İbrahim Koyuncu - 08.03.2020 03:20

ı just started. Best tutorial ever.

Ответить
RD Carreon
RD Carreon - 20.11.2019 14:33

Thank you very much.. It helps me so much to finished my final output.

Ответить
Xavi Iribarren
Xavi Iribarren - 05.09.2019 01:34

Thank you so much. I should change some pieces of code in newest version of Visual Studio 2017, including TableAdapters but everything is working fine excepting Search Box that crashes and sends
System.ArgumentNullException: 'Value cannot be null.
Parameter name: source'
Any idea? Could help with that?
Thank you so much in advance.

Ответить
Mr Jimmy
Mr Jimmy - 14.07.2019 20:01

thank you sooooo much!!! it works!! :)

Ответить
Nikolai Korobeinik
Nikolai Korobeinik - 05.07.2019 17:59

Thanks! That was Great!

Ответить
MetalCaster
MetalCaster - 22.04.2019 17:06

Wow, thank you very much!!!!!

Ответить
Bilal Khan
Bilal Khan - 22.03.2019 00:13

can you please do all of them on ado except entity framework

Ответить
Ash G
Ash G - 25.02.2019 22:33

Great tutorial. Thanks for the hard work. If I want to insert a few columns and have default value set for the others in the table level, I'm getting validation error. Advise?

Ответить
Vicenzo Vendetta
Vicenzo Vendetta - 08.12.2018 10:40

So you talked like this in the past rsrsrsrsrssr

Ответить
Ola Soubra
Ola Soubra - 10.11.2018 15:43

very useful thanks alot

Ответить
Mohammad Abu-Khadra
Mohammad Abu-Khadra - 09.11.2018 11:10

Thank you very much for your tutorials I am learning so much from your channel can send me the code of this tutorial please

Ответить
Chung Nguyễn
Chung Nguyễn - 07.10.2018 10:38

thank you

Ответить
News India
News India - 20.07.2018 18:13

i want a best devloper for desktop application anyone here contact me

Ответить
Mohammad Ahmer Malick
Mohammad Ahmer Malick - 20.04.2018 09:54

great tutorial
i copied your code and its working great but i don not get message when i save duplicate data (id customer) can you help me

Ответить
Elena Coroi
Elena Coroi - 30.03.2018 17:41

Hi,
Great Tutorial, could you please sent me the code? ([email protected])
Thank you !

Ответить
Abuzar Mehmood
Abuzar Mehmood - 13.02.2018 14:29

please help me. I couldn't find the username .
from where i can get this name ?????

Ответить
Mike Dastro
Mike Dastro - 07.02.2018 04:27

Can you make tutorial for inserting in already existing sql database with updating I'd ( primary key) the primary key should be synchronized with all IDs (. For example - you add row between 2&3 and now yours new row I'd should be 3 and the rest should increase to one 3 is 4,4is5 etc. )

Ответить
Julio Aguilar
Julio Aguilar - 18.01.2018 18:27

Excellect. Can you send me the code?
Thanks

Ответить
Low Lixing1213
Low Lixing1213 - 05.12.2017 15:20

why are the things that i wrote in the textbox is not saved in my database

Ответить
Azim Lit.
Azim Lit. - 27.10.2017 17:15

Awesome!!

Ответить
iProComboツ
iProComboツ - 09.10.2017 18:55

What is customerBindingSource?

Ответить