|
Hi,
I am having a problem to update a field in the database, my code is
sqlString = "UPDATE [user] SET logindt='10/9/2007 2:39PM' WHERE email='abc@yahoo.com'"
myCommand = New SqlCommand(sqlString, myConnection)
myCommand.ExecuteNonQuery()
Response.Redirect("main.aspx")
The thing is the page just sort of refresh itself after I click 'Log in' and did not show any error message but the logindt is not updated still.
Could it be permission problem or something else?
Please help me out on this, I'd been cracking my head wondering why since no error message shows.
J Liang
|
|
|
|
|
Hi,
Please post the code you wrote when login button is clicked and also the code under page load of login page.
Mubashir
Every job is a self portrait of the person who did it.
|
|
|
|
|
Hi Mubashir,
Thanks for the reply, here's the code
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim dr As SqlDataReader
Dim currdt As DateTime = DateTime.Now
myConnection = New SqlConnection("server=localhost;uid=aa;pwd=abc;database=ww;Data Source=mysource")
myConnection.Open()
Dim sqlString = "SELECT * FROM [dbo].[user] WHERE email='" & Me.txtEmail.Text & "' AND password='" & Me.txtPwd.Text & "'"
If Me.txtEmail.Text = "" Or Me.txtPwd.Text = "" Then
Me.lblmsg.Text = "Please fill in your email and password"
Else
Try
myCommand = New SqlCommand(sqlString, myConnection)
dr = myCommand.ExecuteReader()
dr.Read()
If dr.HasRows Then
'Set session for later use
Session("uid") = dr(0)
Session("name") = dr(1)
Session("deptid") = dr(2)
Session("title") = dr(3)
Session("grpid") = dr(4)
Session("category") = dr(5)
Session("email") = dr(6)
'Update login time
sqlString = "UPDATE [user] SET logindt='10/9/2007 2:39PM' WHERE email='abc@yahoo.com'"
myCommand = New SqlCommand(sqlString, myConnection)
myCommand.ExecuteNonQuery()
Response.Redirect("main.aspx")
Else
Me.lblmsg.Text = "Email and password incorrect"
End If
dr.Close()
myConnection.Close()
Catch e As Exception
Me.MsgBox(e.ToString())
End Try
End If
Hope this is what you need.
J Liang
|
|
|
|
|
HI,
Your code seems to be fine, Try and run the UPDATE sql in the SQL Query Analyzer and see wat it do. May be it is not fulfilling the WHERE criteria so check the aphabet case as well for the email field.
Mubashir
Every job is a self portrait of the person who did it.
|
|
|
|
|
Hi,
I'd tried running the SQL script using the Enterprise Manager and it works fine, the database is being updated, that is what makes me so confuse on what is wrong with my site.
|
|
|
|
|
ic..
Use the following suggestions
- Are you able to select records from the DB? the idea is to check whether the code is connected with the DB alright. If NO then use the following connection string
"server=yoursvr;uid=uruser;pwd=urpwd;database=SomeDB"
- Try and debug to see whether the Update cmd is executed/parsed or not.
Best of luck
Mubashir
Every job is a self portrait of the person who did it.
|
|
|
|
|
Hi Mubashir,
Thanks for the suggestions. I sort of got it working and the database is being updated as I want it to be.
The thing is when I run two SQL command in the same page, it will not work, so I separated both the SQL command into different page (it's not an issue for my case whether where the command is), so it check the email and password and login to the main page then only it updates the date time.
Still wondering why it doesn't work at first, but anyway, I shall find out myself.
Thanks.
J Liang
|
|
|
|
|
Strange issue, but good that its working.
Mubashir
Every job is a self portrait of the person who did it.
|
|
|
|
|
Did you check the query with Select Clause to see indeed if some records match up your where clause?
|
|
|
|
|
Hi Kumar,
After continuing my project, everything went fine. What I suspect is it was a bit messy, so after I clean things up everything is working fine and I can have a few sql command at a same page.
J Liang
|
|
|
|
|
Hi all
I want to get alert when my web page is idel for 20 min
How it is possible
help me please
Sunil Tvl
|
|
|
|
|
sunilTVL wrote: I want to get alert when my web page is idel for 20 min
Who should be alerted ? You or User ?
|
|
|
|
|
|
i use from this method:
ManagementObjectSearcher MainBoard = new ManagementObjectSearcher("Select * From Win32_BaseBoard");
foreach (ManagementObject mbProperty in MainBoard.Get())
{
lblMbName.Text = mbProperty["Name"].ToString();
lblSerialNumber.Text = mbProperty["SerialNumber"].ToString();
}
the name of mainboard detected but lblSerialNumber.Text always is null, why?
We Can Do Anything, If We Want It
|
|
|
|
|
Hi if i select month and year based on that...,
i need that month all dates in my datagrid...,
Plz help me...,
Magi
|
|
|
|
|
your question is unknown.
We Can Do Anything, If We Want It
|
|
|
|
|
Hi see in one of drop down list box i will select month...,
Another dropdown listbox i will select year...,
Now based on this two inputs,i want to display that month all dates in my datagrid....,
Now u got it my qeustion????????
Plz help me...
Magi
|
|
|
|
|
hi
how can i create a menu ribbon in asp.net without using a third party tool
thanks
|
|
|
|
|
|
Hi All,
I need yearwise scroll in asp.net calender control so I took 2 linkbutton << (for prev year) and >> (for next year). On click event of << I wrote code:
calDate.SelectedDate = calDate.SelectedDate.AddYears(-1)
calDate.VisibleDate = calDate.SelectedDate
but its gives error
System.ArgumentOutOfRangeException: The added or subtracted value results in an un-representable DateTime.
The added or subtracted value results in an un-representable DateTime.
Parameter name: months
For >> I wrote this code:
calDate.SelectedDate = calDate.SelectedDate.AddYears(1)
calDate.VisibleDate = calDate.SelectedDate
But here also its not showing next year properly....
the same code work in ASP.NET 1.1(C#) but its not working in ASP.NET 2.0(VB)
please help me.Its very urgent.
Thanks in advance..
|
|
|
|
|
Hi,
I have a Textbox for which maxLength is 80.If i enter characters in the Textbox i need to display the remaining characters that we can enter.
Example :if we enter 10 characters then it will show like "70 characters Left"
Please Help me.
Thanks and Regards
Narendra
|
|
|
|
|
u can use:
<asp:TextBox Id="txt1" runat="server" onkeypress="CharRemainFinder(this);" MaxLength="80" ></asp:TextBox><span id="RemainChr"></span>
<script>
function CharRemainFinder(txtObj)
{
var span = document.getElementById('RemainChr');
if(span != null)
span.innerHTML = 80 - txtObj.value.length + "characters left";
}
</script>
We Can Do Anything, If We Want It
|
|
|
|
|
Thank You Sir,
It is working
Thanks and Regards
Narendra
|
|
|
|
|
Hi,
I have some static pages in my application, and i want to open those static pages in the Master page.
i want to do so b'coz my static page content keeps on changing, so if i use an HTML page i will not have to re-complie the application.
So i want to know how to load that HTML page in some contentplaeholder or may be some other control.
Please suggest some another way also if u have it in your mind and may be useful to me.
Thanks,
Deepak Surana
|
|
|
|
|
I had the problem like this and laod the file with File.ReadAllText method and put a Label on the page(or Masterpage ) , then set Label.Text to that string. You can also user Literal Control or some other control I guess.
Mazy
"This chancy chancy chancy world....."
|
|
|
|