Kod hatası ?

1 2
01/06/2010, 19:13

alican5335

Dim baglan As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\\ali.mdb")
baglan.Open()
Dim komut As New OleDbCommand("insert into aaa (adi,soyadi) values ('textbox1.text','textbox2.text')", baglan)
komut.ExecuteNonQuery()
label1.text = "kayıt tmm"
baglan.Close()

Komudunu yazıyorum Access baglanınca soyledıgım yerlere textbox1.text'e girilen deger yerine textbox1.text yazıyor nerde hata yaptım ?
01/06/2010, 19:28

yuksoft

Dim komut As New OleDbCommand("insert into aaa (adi,soyadi) values ("+textbox1.text+","+textbox2.text+")", baglan)

Şeklinde deneyin hocam.
01/06/2010, 19:41

alican5335

(01/06/2010, 19:13)alican5335 yazdı: Dim baglan As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\\ali.mdb")
baglan.Open()
Dim komut As New OleDbCommand("insert into aaa (adi,soyadi) values ('textbox1.text','textbox2.text')", baglan)
komut.ExecuteNonQuery()
label1.text = "kayıt tmm"
baglan.Close()

Komudunu yazıyorum Access baglanınca soyledıgım yerlere textbox1.text'e girilen deger yerine textbox1.text yazıyor nerde hata yaptım ?


degisen birşey yok hocam yine aynı textbox1.text yazıyor adi kısmına soyadı kısmınada textbox2.text yazıyor :S
01/06/2010, 19:42

yuksoft

Siz tek tırnak içinde belirtirseniz onu string değer olarak alır.
Dim komut As New OleDbCommand("insert into aaa (adi,soyadi) values ("+textbox1.text+","+textbox2.text+")", baglan)
Bu konu kullanın olmazsa projenizi eklenti olarak ekleyin yardımcı olalım.
01/06/2010, 21:27

alican5335

Imports system.Data.OleDb
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, b As String
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
d = TextBox4.Text
e = TextBox5.Text
f = TextBox6.Text

Dim baglan As New OleDbConnection("provider=microsoft.jet.oledb.4.0; data source=c:\\market.mdb")
baglan.Open()
Dim komut As New OleDbCommand("insert into urun (Barkot_No,Urun_Cinsi,Urun_Adeti,Urun_Adı,Alıs_Fiyatı,Satıs_Fiyatı) values ('" & a & "','" & b & "','" & c & "','" & d & "','" & e & "','" & f & "')", baglan)

Label1.Text = "Kayit Edildi"
komut.ExecuteNonQuery()
baglan.Close()

End Sub
End Class




Şöyle birşey yaparık durumu hallettim fakat şşimdide ave b ye string degeri verdim f ye ise para birimi degeri vermem gerek string yerine ne yazıcam

yani metin,tarihsaat,para birimi kodları ne ?
22/07/2010, 02:12

hydramses

hocam insert ederken textbox'tan verilier ' " & textbox1.text & " ' bu şekilde al
1 2