Visual Studio sql Server hata
02.05.2020 - 09:33
Bu benim frmMusteriListele Kodum
Public Class frmMusteriListele
Sub Temizle()
For Each control As Control In Me.Controls
If TypeOf control Is TextBox Then
control.Text = ""
End If
Next
End Sub
Dim S As New Stok
Private Sub frmMusteriListele_Load(sender As Object, e As EventArgs) Handles MyBase.Load
S.KayitGetir("select *from musteri", DataGridView1)
End Sub
Private Sub txtMusteriSearch_TextChanged(sender As Object, e As EventArgs) Handles txtMusteriSearch.TextChanged
S.KayitGetir("select *from musteri where adSoyad like '%" & txtMusteriSearch.Text & "%'", DataGridView1)
End Sub
Private Sub btnmusteriGuncelle_Click(sender As Object, e As EventArgs) Handles btnmusteriGuncelle.Click
S.Ekle_Sil_Guncelle("update musteri set adSoyad='" & TxtMusGuncelleAdSoyad.Text & "',where veresiye='" & txtGuncelleVeresiye.Text & "'")
S.KayitGetir("select *from musteri", DataGridView1)
End Sub
Private Sub iptalButton_Click(sender As Object, e As EventArgs) Handles iptalButton.Click
Me.Close()
End Sub
Private Sub silButton_Click(sender As Object, e As EventArgs) Handles silButton.Click
S.Ekle_Sil_Guncelle("delete from musteri where adSoyad='" & DataGridView1.CurrentRow.Cells(0).Value.ToString & "'")
S.KayitGetir("select *from musteri", DataGridView1)
End Sub
Private Sub DataGridView1_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
TxtMusGuncelleAdSoyad.Text = DataGridView1.CurrentRow.Cells(0).Value.ToString
txtGuncelleVeresiye.Text = DataGridView1.CurrentRow.Cells(1).Value.ToString
End Sub
End Class
Bu da benim Stok.vb class ındaki kodum:
Imports System.Data.SqlClient
Public Class Stok
Dim baglanti As New SqlConnection("Data Source=.\sqlexpress;Initial Catalog=MarkePro;Integrated Security=True")
Dim tablo As New DataTable
Sub Ekle_Sil_Guncelle(sorgu As String)
Try
If baglanti.State = ConnectionState.Closed Then
baglanti.Open()
End If
Dim komut As New SqlCommand(sorgu, baglanti)
komut.ExecuteNonQuery()
baglanti.Close()
MessageBox.Show("İşlem Başarılı")
frmMusteriEkle.Temizle()
frmMusteriListele.Temizle()
Catch ex As Exception
baglanti.Close()
MessageBox.Show("Böyle Bir Müşteri Bulunuyor!", "Uyarı")
End Try
End Sub
Sub KayitGetir(sorgu As String, dgrid As DataGridView)
tablo.Clear()
Dim adtr As New SqlDataAdapter(sorgu, baglanti)
adtr.Fill(tablo)
dgrid.DataSource = tablo
End Sub
End Class
Sorun şu ki ben sql üzerindeki veriden frmMusteriListele kodunda da gördüğünüz gibi veri güncellemeye çalışıyorum.
private Sub btnMusteriguncelle diye başlayan kısımdaki bir kodda hata olduğunu düşünüyorum ama çözemedim.
---------------------Teşekkürler-------------
104
Görüntülenme
0 Beğeni