Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,153,217 members, 7,818,744 topics. Date: Sunday, 05 May 2024 at 11:53 PM |
Nairaland Forum / Science/Technology / Programming / Vb.net Update Error (1064 Views)
I Need A Help To Write A Simple Login Form Using Vb.net / Vb.net Crystal Report & Dataset / Post Ur Vb 6.0 Questions Here (2) (3) (4)
Vb.net Update Error by bigafees: 12:50pm On Nov 09, 2010 |
Please assist me with this code it given me error mystring = "update Admission SET Disch_date= " & TextBoxdischdate.Text & " ,disch_time = " & TextBoxdischtime.Text & " ,Days_spent = " & TextBoxdays.Text & " ,Disch_Status= " & textboxstatus.Text & " where medical_Id = " & TextBoxid.Text & " and Adm_date =" & Date.Parse(TextBoxadmdate.Text) & "" mycmd.CommandText = mystring mycon.Open() mycmd.ExecuteNonQuery() mycon.Close() it complain at mycmd.ExecuteNonQuery() |
Re: Vb.net Update Error by TBits: 1:15pm On Nov 09, 2010 |
if the underlying database columns are varchar and datetime, then you are to send the values to the database enclosed in single quotes which you are not doing e.g ' " & texbox1.text & " ' " |
Re: Vb.net Update Error by Nobody: 2:07pm On Nov 09, 2010 |
you should enclose all your controls in single qoute as in '" & name=text1.text & "' |
Re: Vb.net Update Error by Kobojunkie: 5:53pm On Nov 10, 2010 |
@Poster, first problem I see . . . .You do not inform us exactly of what the compiler complaints were. Secondly, you ought to be using parameterized queries by now. Even better, try to avoid inline SQL wherever you can instead. What you have up there is recipe for SQL Injection Anyways, do post the actual error message and we can better help. |
Re: Vb.net Update Error by dazz4me: 8:43am On Nov 11, 2010 |
So many things is wrong with your query. First i think its easier and better to use parameterised query. And use single quote for your values |
Re: Vb.net Update Error by bigafees: 10:18am On Nov 11, 2010 |
Thanx, I have solved the problem with your posts I have problem with this also, i have google it but no suitable solution command.CommandText = "Select count(*) as nob from Admission where medical_id='" & txtmedid.Text & "' and disch_date IS NULL" connection.Open() command.ExecuteScalar() If ("nob" > 1 Then Label1.Text = "The Patient is currently on Admission, Discharge First " Else it complaining at If ("nob" > 1 Then pls assit me house, i'm teaching myself on vb.net |
Re: Vb.net Update Error by TBits: 4:04pm On Nov 11, 2010 |
you cannot test the column name you are retrieving (nob) rather you should be testin the value the column retrieves try the following below command.CommandText = "Select count(*) as nob from Admission where medical_id='" & txtmedid.Text & "' and disch_date IS NULL" connection.Open() dim value as long value = Convert.ToInt32(cmd.ExecuteScalar()) if value > 1 Label1.Text = "The Patient is currently on Admission, Discharge First " Else |
(1) (Reply)
Free Natural Language Proccessing / Please Anyone That Has As Idea On Expert Systems / Programming For Learners. The Basics
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10 |