Комментарии:
is there a difference if I use it windows authorized?
ОтветитьSo helpful! Any chance you could send me the source code? I'm stuck on the entity part but trying to solve it myself.
ОтветитьIs there a difference between the local database and SQL server?
Ответить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.
Ответитьgreat )
ОтветитьThis is great. Can you please send me the code. [[email protected]]
Ответить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();
}
}
}
}
}
Awesome 👍
Ответитьı just started. Best tutorial ever.
ОтветитьThank you very much.. It helps me so much to finished my final output.
Ответить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.
thank you sooooo much!!! it works!! :)
ОтветитьThanks! That was Great!
ОтветитьWow, thank you very much!!!!!
Ответитьcan you please do all of them on ado except entity framework
Ответить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?
ОтветитьSo you talked like this in the past rsrsrsrsrssr
Ответитьvery useful thanks alot
ОтветитьThank you very much for your tutorials I am learning so much from your channel can send me the code of this tutorial please
Ответитьthank you
Ответитьi want a best devloper for desktop application anyone here contact me
Ответить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
Hi,
Great Tutorial, could you please sent me the code? ([email protected])
Thank you !
please help me. I couldn't find the username .
from where i can get this name ?????
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. )
ОтветитьExcellect. Can you send me the code?
Thanks
why are the things that i wrote in the textbox is not saved in my database
ОтветитьAwesome!!
ОтветитьWhat is customerBindingSource?
Ответить