PDA

View Full Version : سوال: مشکل تایپی این کد



farhad85
جمعه 18 بهمن 1392, 17:46 عصر
سلام روستا مشکل این کد چیه که این خطارو میده:

Dim my_cm4 As New SqlCommand("UPDATE moshakhasat SET (code_meli=@code_melinew,name=@name,family=@family ,n_p=@n_p,sh_sh=@sh_sh,t_t=@t_t,m_sodur=@m_sodur,t ahsilat=@tahsilat,reshte=@reshte,shoghl=@shoghl,ta ahol=@taahol,t_khanevade=@t_khanevade,sokunat=@sok unat,ostan=@ostan,shahrestan=@shahrestan,bakhsh=@b akhsh,dehestan=@dehestan,rusta=@rusta,m_khadamat=@ m_khadamat,n_shora=@n_shora,h_shora=@h_shora,n_deh yar=@n_dehyar,h_dehyar=@h_dehyar,sh_hesab=@sh_hesa b,sh_cart=@sh_cart,h_keshavarz=@h_keshavarz,code_p osti=@code_posti,email=@email,t_sabtename=@t_sabte name,m_sabt=@m_sabt,adres=@adres,toz=@toz,pic=@pic where code_meli=@code_meli)", my_cn)




خطا:An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: Incorrect syntax near '('.

damanpak
جمعه 18 بهمن 1392, 20:07 عصر
سلام
توی کدت پرانتز باز و بسته رو بردار
اینو جایگزین کن
Dim my_cm4 As New SqlCommand("UPDATE moshakhasat SET code_meli=@code_melinew,name=@name,family=@family ,n_p=@n_p,sh_sh=@sh_sh,t_t=@t_t,m_sodur=@m_sodur,t ahsilat=@tahsilat,reshte=@reshte,shoghl=@shoghl,ta ahol=@taahol,t_khanevade=@t_khanevade,sokunat=@sok unat,ostan=@ostan,shahrestan=@shahrestan,bakhsh=@b akhsh,dehestan=@dehestan,rusta=@rusta,m_khadamat=@ m_khadamat,n_shora=@n_shora,h_shora=@h_shora,n_deh yar=@n_dehyar,h_dehyar=@h_dehyar,sh_hesab=@sh_hesa b,sh_cart=@sh_cart,h_keshavarz=@h_keshavarz,code_p osti=@code_posti,email=@email,t_sabtename=@t_sabte name,m_sabt=@m_sabt,adres=@adres,toz=@toz,pic=@pic where code_meli=@code_meli", my_cn)

farhad85
جمعه 18 بهمن 1392, 20:21 عصر
ممنون ایم کارو کردم ولی این خطا ظاهر شد
Additional information: Must declare the scalar variable "@code_meli".

farhad85
جمعه 18 بهمن 1392, 20:22 عصر
من شرطم بر اساس کد ملی هستش

farhad85
جمعه 18 بهمن 1392, 20:31 عصر
ممنــــــــــــــــــــــ ـــــــــــــــــــــــــ ـــــــــــــونم

farhad85
جمعه 18 بهمن 1392, 20:32 عصر
این کدشه کلا

Dim my_da4 As New SqlDataAdapter("Select * from moshakhasat", my_cn)

Dim my_ds4 As New DataSet

Dim my_cb4 As New SqlCommandBuilder(my_da4)

Dim my_cm4 As New SqlCommand("UPDATE moshakhasat SET code_meli=@code_meli,name=@name,family=@family,n_p =@n_p,sh_sh=@sh_sh,t_t=@t_t,m_sodur=@m_sodur,tahsi lat=@tahsilat,reshte=@reshte,shoghl=@shoghl,taahol =@taahol,t_khanevade=@t_khanevade,sokunat=@sokunat ,ostan=@ostan,shahrestan=@shahrestan,bakhsh=@bakhs h,dehestan=@dehestan,rusta=@rusta,m_khadamat=@m_kh adamat,n_shora=@n_shora,h_shora=@h_shora,n_dehyar= @n_dehyar,h_dehyar=@h_dehyar,sh_hesab=@sh_hesab,sh _cart=@sh_cart,h_keshavarz=@h_keshavarz,code_posti =@code_posti,email=@email,t_sabtename=@t_sabtename ,m_sabt=@m_sabt,adres=@adres,toz=@toz,pic=@pic where code_meli=@code_meli", my_cn)

DataGridView1.Enabled = True



my_cn.Open()

my_cm4.ExecuteNonQuery()


my_da4.Fill(my_ds4, "moshakhasat")



DataGridView1.DataSource = (my_ds4)


DataGridView1.DataMember = "moshakhasat"



my_cn.Close()

damanpak
جمعه 18 بهمن 1392, 20:34 عصر
دوست عزیز باید متغییر هاتو توی کد اس کیو الت تعریف کنی
ضمنا این کدنویسیت اشتباهه
آخه اطلاعات جدید رو از تکستهای داخل برنامه ات باید بگیری نه از متغییرهای اس کیو ال

farhad85
جمعه 18 بهمن 1392, 20:37 عصر
یعنی این شکلی منظورته؟

Dim my_da4 As New SqlDataAdapter("Select * from moshakhasat", my_cn)

Dim my_ds4 As New DataSet

Dim my_cb4 As New SqlCommandBuilder(my_da4)

Dim my_cm4 As New SqlCommand("update moshakhasat set family=N'" & TextBox3.Text & "',code_meli=N'" & _

TextBox1.Text & "',name=N'" & TextBox2.Text & "',n_p=N'" & TextBox4.Text & _

"',sh_sh=N'" & TextBox5.Text & "',t_t=N'" & MaskedTextBox1.Text & "',m_sodur=N'" & _

TextBox6.Text & "',tahsilat=N'" & ComboBox1.Text & "',RESHTE=N'" & TextBox7.Text & _

"',SHOGHL=N'" & ComboBox2.Text & "',TAAHOL=N'" & ComboBox3.Text & "',T_KHANEVADE=N'" & _

TextBox8.Text & "',SOKUNAT=N'" & ComboBox4.Text & "',OSTAN=N'" & ComboBox5.Text & _

"',SHAHRESTAN=N'" & ComboBox6.Text & "',bakhsh=N'" & TextBox9.Text & "',dehestan=N'" & TextBox10.Text & _

"',rusta=N'" & TextBox11.Text & "',m_khadamat=N'" & TextBox12.Text & "',n_shora=N'" & TextBox13.Text & _

"',h_shora=N'" & TextBox14.Text & "',n_dehyar=N'" & TextBox15.Text & "',h_dehyar=N'" & TextBox16.Text & _

"',sh_hesab=N'" & TextBox17.Text & "',sh_cart=N'" & TextBox18.Text & "',h_keshavarz=N'" & TextBox19.Text & _

"',code_posti=N'" & TextBox20.Text & "',t_sabtename=N'" & MaskedTextBox2.Text & "',m_sabt=N'" & TextBox21.Text & _

"',email=N'" & TextBox22.Text & "',adres=N'" & TextBox23.Text & "',toz=N'" & TextBox24.Text & "' where code_meli='" & TextBox1.Text & "'", my_cn)



my_cn.Open()

my_cm4.ExecuteNonQuery()


my_da4.Fill(my_ds4, "moshakhasat")



DataGridView1.DataSource = (my_ds4)


DataGridView1.DataMember = "moshakhasat"



my_cn.Close()

damanpak
جمعه 18 بهمن 1392, 20:38 عصر
آره.این کد درسته

farhad85
جمعه 18 بهمن 1392, 20:40 عصر
اگه بخوام با پارامتر اینکارو کنم یعنی نمیشه

farhad85
جمعه 18 بهمن 1392, 20:41 عصر
آخه این کد عکسمو ویرایش نمیکنه بخاطر همین هم از پارامترها استفاده کردم

damanpak
جمعه 18 بهمن 1392, 21:40 عصر
خب توی سورس شما فیلد عکس کدومه؟

farhad85
جمعه 18 بهمن 1392, 21:44 عصر
pic=@pic
هستش

damanpak
جمعه 18 بهمن 1392, 22:13 عصر
دوست عزیز شما باید مسیر عکس رو مثل کدی که در پست هشتم گذاشتید به اس کیو ال ارسال کنید

farhad85
شنبه 19 بهمن 1392, 14:19 عصر
به هر حال ممنونم از راهنمایی شما