eulogy6
Programmer
- Apr 30, 2004
- 26
I get an error "Input string was not in a correct format"
and I don't understand why?
I'm going to use the following code in order to change the user's password with the "newtxt1.Text", having an Access database with 1 table(Users) with UserID|Username|Password.
Can anyone tell me what I'm doing wrong?
Thanx in advanced
.............................................
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Me.Lblkey.Text = Request.QueryString("Key")
UpdateGrid()
End If
End Sub
Private Sub UpdateGrid()
Me.OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("bin\users.mdb")&"
Me.OleDbSelectCommand1.CommandText = "Select * from Users where UserID = '" & Me.Lblkey.Text & "'"
Me.OleDbConnection1.Open()
Me.OleDbDataAdapter1.SelectCommand.CommandText = Me.OleDbSelectCommand1.CommandText
Me.OleDbDataAdapter1.Update(Me.DataSetCompanies1)
Me.OleDbDataAdapter1.Fill(Me.DataSetCompanies1)
Me.OleDbConnection1.Close()
Me.txtusername.DataBind()
Me.txtpassword.DataBind()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyCon As OleDb.OleDbConnection
Dim MyCommand As OleDb.OleDbCommand
Dim MySql As String
MyCon = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("bin\users.mdb")&"
MySql = "UPDATE Users SET Password=@Pas WHERE UserID = @ID"
MyCommand = New OleDb.OleDbCommand(MySql, MyCon)
MyCommand.Parameters.Add(New OleDb.OleDbParameter("@Pas", SqlDbType.Char, 50))
MyCommand.Parameters.Add(New OleDb.OleDbParameter("@ID", SqlDbType.Char, 50))
MyCommand.Parameters("@Pas").Value = Me.newtxt1.Text
MyCommand.Parameters("@ID").Value = Me.Lblkey.Text
MyCommand.Connection.Open()
MyCommand.ExecuteNonQuery()
MyCommand.Connection.Close()
UpdateGrid()
End Sub
and I don't understand why?
I'm going to use the following code in order to change the user's password with the "newtxt1.Text", having an Access database with 1 table(Users) with UserID|Username|Password.
Can anyone tell me what I'm doing wrong?
Thanx in advanced
.............................................
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Me.Lblkey.Text = Request.QueryString("Key")
UpdateGrid()
End If
End Sub
Private Sub UpdateGrid()
Me.OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("bin\users.mdb")&"
Me.OleDbSelectCommand1.CommandText = "Select * from Users where UserID = '" & Me.Lblkey.Text & "'"
Me.OleDbConnection1.Open()
Me.OleDbDataAdapter1.SelectCommand.CommandText = Me.OleDbSelectCommand1.CommandText
Me.OleDbDataAdapter1.Update(Me.DataSetCompanies1)
Me.OleDbDataAdapter1.Fill(Me.DataSetCompanies1)
Me.OleDbConnection1.Close()
Me.txtusername.DataBind()
Me.txtpassword.DataBind()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyCon As OleDb.OleDbConnection
Dim MyCommand As OleDb.OleDbCommand
Dim MySql As String
MyCon = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("bin\users.mdb")&"
MySql = "UPDATE Users SET Password=@Pas WHERE UserID = @ID"
MyCommand = New OleDb.OleDbCommand(MySql, MyCon)
MyCommand.Parameters.Add(New OleDb.OleDbParameter("@Pas", SqlDbType.Char, 50))
MyCommand.Parameters.Add(New OleDb.OleDbParameter("@ID", SqlDbType.Char, 50))
MyCommand.Parameters("@Pas").Value = Me.newtxt1.Text
MyCommand.Parameters("@ID").Value = Me.Lblkey.Text
MyCommand.Connection.Open()
MyCommand.ExecuteNonQuery()
MyCommand.Connection.Close()
UpdateGrid()
End Sub