Hỏi đáp
Chia sẻ kiến thức, cùng nhau phát triển
toàn code của mình đó bạn.....bạn thêm chức năng chèn ảnh đi...để mình chụp lại lỗi.... lỗi chỉ ngay dòng mt.SubmitChanges(); nó ghi SQLException was unhandled
//Class chứa data từ sql
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace computer
{
public class MayTinh
{
computerDataContext mt;
public MayTinh()
{
mt = new computerDataContext();
}
public List<tblPhonghoc> showtree()
{
return mt.tblPhonghocs.Select(t => t).ToList();
}
public List<tblMaytinh> computershow(string maPhong)
{
return mt.tblMaytinhs.Where(t => t.msPhong==maPhong).ToList();
}
public List<tblPhonghoc> classshow()
{
return mt.tblPhonghocs.Select(t => t).ToList();
}
public void addclass(tblPhonghoc e)
{
mt.tblPhonghocs.InsertOnSubmit(e);
mt.SubmitChanges();
}
}
//Form của mình
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using computer;
namespace QL_MayTinh
{
public partial class Form2 : Form
{
computerDataContext cp;
private MayTinh mt;
private tblPhonghoc ph;
public Form2(Form1 _f1)
{
cp = new computerDataContext();
mt = new MayTinh();
ph = new tblPhonghoc();
InitializeComponent();
//lvclass.View = View.Details;
}
private void Form2_Load(object sender, EventArgs e)
{
BindingSource b = new BindingSource();
b.DataSource = mt.classshow();
dataGridView1.DataSource = b;
bindingNavigator1.BindingSource = b;
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
ph.msPhong=dataGridView1.SelectedRows[0].Cells[0].ToString();
ph.tenPhong = dataGridView1.SelectedRows[0].Cells[1].ToString();
ph.toaNha = dataGridView1.SelectedRows[0].Cells[2].ToString();
ph.tanglau =Convert.ToInt16( dataGridView1.SelectedRows[0].Cells[3].Value);
mt.addclass(ph);
}
}
}
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
toàn code của mình đó bạn.....bạn thêm chức năng chèn ảnh đi...để mình chụp lại lỗi.... lỗi chỉ ngay dòng mt.SubmitChanges(); nó ghi SQLException was unhandled
Để sử dụng tính năng này, Bạn cần đăng nhập bằng tài khoản Howkteam.
Đăng nhập
Để xem được nội dung và giúp Kteam duy trì hoạt động.
Bạn vui lòng tắt Adblock trên website howkteam.vn nhé!
bạn đã có câu hỏi này trước đó.
vui lòng update lại câu hỏi cũ chứ không post câu hỏi mới lên như vầy
còn ảnh chụp bạn có thể upload lên bất kỳ server ảnh nào
thân. bài này sẽ bị xóa vả chuyển code sang bài cũ