Click here to Skip to main content
15,887,746 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Error in Update & Insert Statement Pin
Luc Pattyn8-Feb-09 4:39
sitebuilderLuc Pattyn8-Feb-09 4:39 
GeneralRe: Error in Update & Insert Statement Pin
Vikash Yadav8-Feb-09 17:01
Vikash Yadav8-Feb-09 17:01 
AnswerRe: Error in Update & Insert Statement Pin
Dave Kreskowiak8-Feb-09 5:21
mveDave Kreskowiak8-Feb-09 5:21 
GeneralRe: Error in Update & Insert Statement Pin
paas8-Feb-09 8:08
paas8-Feb-09 8:08 
GeneralRe: Error in Update & Insert Statement Pin
Dave Kreskowiak8-Feb-09 13:18
mveDave Kreskowiak8-Feb-09 13:18 
GeneralRe: Error in Update & Insert Statement Pin
Vikash Yadav8-Feb-09 18:25
Vikash Yadav8-Feb-09 18:25 
GeneralRe: Error in Update & Insert Statement Pin
Dave Kreskowiak9-Feb-09 1:45
mveDave Kreskowiak9-Feb-09 1:45 
AnswerRe: Error in Update & Insert Statement Pin
Vimalsoft(Pty) Ltd8-Feb-09 22:22
professionalVimalsoft(Pty) Ltd8-Feb-09 22:22 
Dave is right,with the code like this you will be exposed to SQl Injection.

When i installed VS i did not install VB.NET , so i will try to show you how to do it i C# you can easly convert it to vb.net


first you need to create a Stored Procedure like this

SQL
Create PROC prc_Update
(
@Password varchar(40),
@UserID int
)
AS
Update tblLogin 
set Password=@Password
where UserID =@UserID


now regarding the ID, you must find another way, mybe use a username,but you have to make sure there is no Duplicate username because you might end up updating wrong records

and your C# or VB.NET should look like this
C#
String strcon = ConfigurationManager.AppSettings.Get("MYConnectionstring");

       SqlConnection con;

       SqlCommand cmdupdate;

       public int Update_Password(String Password,int id)
       {
           con = new SqlConnection(strcon);

           cmdupdate = new SqlCommand();

           cmdupdate.CommandText = "dbo.prc_Update";

           cmdupdate.CommandTimeout = 0;

           cmdupdate.CommandType = CommandType.StoredProcedure;

           cmdupdate.Parameters.Add("@Password", SqlDbType.VarChar, 40).Value = Password;

           cmdupdate.Parameters.Add("@UserID", SqlDbType.Int, 4).Value = id;

           cmdupdate.Connection = con;

           int Results = 0;

           try
           {
               con.Open();

             Results = cmdupdate.ExecuteNonQuery();

           }
           catch (SqlException)
           {
               throw;
           }
           finally
           {
               con.Close();
           }
           return Results;

       }


Lastly you must stop feeding the database wrong info.The Data types and demension should be the same and you will not have any Problems
Hope you get an idea

Vuyiswa Maseko,

Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswam@its.co.za


Questioncan anyone help me in making an application of blood donors information service. Pin
neetu1497-Feb-09 10:04
neetu1497-Feb-09 10:04 
AnswerRe: can anyone help me in making an application of blood donors information service. Pin
vaghelabhavesh7-Feb-09 11:17
vaghelabhavesh7-Feb-09 11:17 
GeneralRe: thankyou so much. Pin
neetu14910-Feb-09 8:04
neetu14910-Feb-09 8:04 
AnswerRe: can anyone help me in making an application of blood donors information service. Pin
vigylant7-Feb-09 11:33
vigylant7-Feb-09 11:33 
AnswerRe: can anyone help me in making an application of blood donors information service. Pin
Christian Graus8-Feb-09 9:14
protectorChristian Graus8-Feb-09 9:14 
GeneralRe: can anyone help me in making an application of blood donors information service. Pin
Jon_Boy9-Feb-09 7:18
Jon_Boy9-Feb-09 7:18 
GeneralRe: thankyou so much. Pin
neetu14910-Feb-09 8:07
neetu14910-Feb-09 8:07 
AnswerRe: can anyone help me in making an application of blood donors information service. Pin
EliottA8-Feb-09 13:50
EliottA8-Feb-09 13:50 
AnswerRe: can anyone help me in making an application of blood donors information service. Pin
Tom Deketelaere9-Feb-09 0:24
professionalTom Deketelaere9-Feb-09 0:24 
GeneralRe: can anyone help me in making an application of blood donors information service. Pin
EliottA9-Feb-09 2:03
EliottA9-Feb-09 2:03 
GeneralRe: thankyou so much. Pin
neetu14910-Feb-09 8:09
neetu14910-Feb-09 8:09 
QuestionChange my IP with New IP Pin
ivo757-Feb-09 7:55
ivo757-Feb-09 7:55 
AnswerRe: Change my IP with New IP Pin
vaghelabhavesh7-Feb-09 11:21
vaghelabhavesh7-Feb-09 11:21 
AnswerRe: Change my IP with New IP Pin
Ranjit Viswakumar8-Feb-09 6:02
Ranjit Viswakumar8-Feb-09 6:02 
GeneralRe: Change my IP with New IP Pin
ivo759-Feb-09 6:51
ivo759-Feb-09 6:51 
Questionenhancement Pin
mjrose7-Feb-09 7:18
mjrose7-Feb-09 7:18 
AnswerRe: enhancement Pin
vaghelabhavesh7-Feb-09 12:03
vaghelabhavesh7-Feb-09 12:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.