|
发表于 30-5-2006 10:47 AM
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 30-5-2006 01:20 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 30-5-2006 01:26 PM
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 30-5-2006 11:02 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 30-5-2006 11:08 PM
|
显示全部楼层
现在把你的整行code贴出来好吗??? 还有... 之前login的page还有问题吗??? |
|
|
|
|
|
|
|
发表于 30-5-2006 11:40 PM
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 31-5-2006 01:08 PM
|
显示全部楼层
原帖由 小妞儿 于 30-5-2006 11:08 PM 发表
现在把你的整行code贴出来好吗??? 还有... 之前login的page还有问题吗???
我写成这样就没有问题。
login也没有问题。。
- '"&request("username")&"'"
复制代码
原帖由 goatstudio 于 30-5-2006 11:40 PM 发表
不如这样吧... 你是说你的 delete 不能运作, 对吗?
你用 debug trace 把那 sql variable 找出来, 贴在这里... 让我们看看那 sql 究竟有什么在里头...
这个要如何做??
不是我的delete不能
是我不能用@uname
只要我改成
- '"&request("username")&"'"
复制代码
就没有问题了。。。。。 |
|
|
|
|
|
|
|
发表于 1-6-2006 12:47 AM
|
显示全部楼层
原帖由 红发 于 31-5-2006 01:08 PM 发表
'"&request("username")&"'"
你的username是从username textbox拿来的??? |
|
|
|
|
|
|
|

楼主 |
发表于 1-6-2006 10:36 PM
|
显示全部楼层
原帖由 小妞儿 于 1-6-2006 12:47 AM 发表
你的username是从username textbox拿来的???
对的,我是这样写
- <asp:TextBox ID="username" Runat="server" Columns="20"/>
复制代码 |
|
|
|
|
|
|
|
发表于 2-6-2006 12:33 AM
|
显示全部楼层
原帖由 红发 于 1-6-2006 10:36 PM 发表
对的,我是这样写
<asp:TextBox ID="username" Runat="server" Columns="20"/>
我想我知道问题在哪儿了... mysql的query不能用@... 必须用?... 也就是说... select ... from... where username=?uname... 然后再改一改parameter的部分... .. 试试看吧... 希望可以... |
|
|
|
|
|
|
|
发表于 2-6-2006 09:39 PM
|
显示全部楼层
既然没error 我先排除connection有问题的可能。。
先从query开刀
有没有试过直接写个query 不要pass parameter
像- Delete From usertable where username = 'milktin'
复制代码 |
|
|
|
|
|
|
|

楼主 |
发表于 2-6-2006 10:07 PM
|
显示全部楼层
原帖由 milktin 于 2-6-2006 09:39 PM 发表
既然没error 我先排除connection有问题的可能。。
先从query开刀
有没有试过直接写个query 不要pass parameter
像 Delete From usertable where username = 'milktin'
因该可以。。
因为我用
Delete From usertable where username = '"&Request("username")&"'
就没有问题了。。。 |
|
|
|
|
|
|
|

楼主 |
发表于 2-6-2006 10:26 PM
|
显示全部楼层
原帖由 小妞儿 于 2-6-2006 12:33 AM 发表
我想我知道问题在哪儿了... mysql的query不能用@... 必须用?... 也就是说... select ... from... where username=?uname... 然后再改一改parameter的部分... .. 试试看吧... 希望可以...

中招了。。。。
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Exception Details: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source Error:
Source Error:没有东西。。。 |
|
|
|
|
|
|
|
发表于 3-6-2006 12:36 AM
|
显示全部楼层
原帖由 红发 于 2-6-2006 10:26 PM 发表

中招了。。。。
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Exception Details: System.AccessViolationException: Attempted to r ...
mySQL 的 parameter 的资料... 看看...
点击 |
|
|
|
|
|
|
|

楼主 |
发表于 3-6-2006 08:40 AM
|
显示全部楼层
原帖由 小妞儿 于 3-6-2006 12:36 AM 发表
mySQL 的 parameter 的资料... 看看...
点击
keke,知道了
要这样
- <%@ Import NameSpace="System.Data" %>
- <%@ Import NameSpace="system.Data.odbc" %>
- <%@ Page Language="vb" Debug="true" trace="true" %>
- <script language="vb" runat="server">
- Sub My_click(Sender As Object,E As EventArgs)
- Dim Conn As String = ConfigurationManager.ConnectionStrings("Connstri").ConnectionString
- Dim dbcon As New OdbcConnection(Conn)
-
- Dim uname As String = Replace(Trim(username.Text), "'", "''")
- Dim pwd As String = Replace(Trim(password.Text), "'", "''")
-
- Dim sql As String = "SELECT pass FROM usertable WHERE username = ?"
-
- Dim cmd As New OdbcCommand(sql, dbcon)
-
- dbcon.open()
-
- Dim param As New OdbcParameter
-
- param = cmd.Parameters.Add("", OdbcType.VarChar, 50)
- param.Direction = ParameterDirection.Input
- param.Value = uname
-
- Response.write(param)
-
- Dim dr As OdbcDataReader = cmd.ExecuteReader()
-
- If dr.Read() Then
-
- If Trim(dr("pass")) = pwd Then
- FormsAuthentication.SetAuthCookie(uname, False)
- FormsAuthentication.RedirectFromLoginPage(uname, False)
- Response.Redirect("xx.html")
- Else
- lblAlert.Text = "Wrong password"
- End If
-
- Else
- lblAlert.Text = "Wrong Username"
- End If
- dr.close()
- dbcon.close()
-
-
- Response.write(uname)
- Response.write("<br>")
- Response.write(pwd)
- End Sub
- </script>
- <html>
- <head>
- <meta http-equiv="Content-Language" content="en-us">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Login</title>
- </head>
- <body>
- <form runat="server">
- <table border="0" width="100%" cellspacing="0" cellpadding="0" id="table1">
- <tr>
- <td width="104"> </td>
- <td><asp:Label ID="lblAlert" Runat="server" Text="Please Key In Username And Password"/></td>
- </tr>
- <tr>
- <td width="104">username</td>
- <td><asp:TextBox ID="username" Runat="server" Columns="20"/></td>
- </tr>
- <tr>
- <td width="104">password</td>
- <td><asp:TextBox ID="password" Runat="server" Columns="20"/></td>
- </tr>
- <tr>
- <td colspan="2"><asp:Button id="My" runat="server" OnClick="My_click" Text="Login"/>
- </td>
- </tr>
- </table>
- </form>
- </body>
- </html>
复制代码
原来是parameter的问题。。。。。。
怪不得Response.write(param)的时候那个value有问题。。。。
这里也有很多。。。
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpref/html/frlrfsystemdataodbcodbccommandclassparameterstopic.asp
[ 本帖最后由 红发 于 3-6-2006 08:41 AM 编辑 ] |
|
|
|
|
|
|
|
发表于 3-6-2006 08:43 AM
|
显示全部楼层
原帖由 红发 于 3-6-2006 08:40 AM 发表
原来是parameter的问题。。。。。。
早说了... 只是我不熟悉mysql的parameter... 所以一直出错... 后来几经波折... 终于找到odbc的parameter的写法...  |
|
|
|
|
|
|
|

楼主 |
发表于 3-6-2006 08:49 AM
|
显示全部楼层
原帖由 小妞儿 于 3-6-2006 08:43 AM 发表
早说了... 只是我不熟悉mysql的parameter... 所以一直出错... 后来几经波折... 终于找到odbc的parameter的写法...
刚刚发现一个问题就是text box不能空,要不然就中error了。
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. |
|
|
|
|
|
|
|
发表于 3-6-2006 08:53 AM
|
显示全部楼层
原帖由 红发 于 3-6-2006 08:49 AM 发表
刚刚发现一个问题就是text box不能空,要不然就中error了。
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
如果那个textbox的资料是必需的... 那么用try... catch...来throw exception... 来告诉用户不能为空... 如果是不必要的... 看看mysql能不能在某个column set类似allow null之类的property...  |
|
|
|
|
|
|
|

楼主 |
发表于 3-6-2006 09:04 AM
|
显示全部楼层
原帖由 小妞儿 于 3-6-2006 08:53 AM 发表
如果那个textbox的资料是必需的... 那么用try... catch...来throw exception... 来告诉用户不能为空... 如果是不必要的... 看看mysql能不能在某个column set类似allow null之类的property...
我用RequiredFieldValidator来解决。
听说try...catch之类的很吃力。。。。
所以不用。。。。
但是还是要谢谢你小妞儿。。。。
所以说帮人不是没有好处的。。。
还是可以学到一些奇怪的东西。。。。 |
|
|
|
|
|
|
|
发表于 3-6-2006 09:59 AM
|
显示全部楼层
原帖由 红发 于 3-6-2006 09:04 AM 发表
....
所以说帮人不是没有好处的。。。
还是可以学到一些奇怪的东西。。 ...
不客气...
但我帮人不是为了好处... 哈哈...   |
|
|
|
|
|
|
| |
本周最热论坛帖子
|