佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

123
返回列表 发新帖
楼主: 红发

一些.net的问题

[复制链接]
发表于 30-5-2006 10:47 AM | 显示全部楼层
原帖由 红发 于 30-5-2006 09:23 AM 发表
回小妞儿

不是我不要写error出来。。。

是没有error我如何写。。。。


我也没强逼你贴出来... 只是贴出来能让大家更明白错误的地方... 也能对症下药... 我也只是只是想更早帮你解决问题...
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 30-5-2006 01:20 PM | 显示全部楼层
原帖由 小妞儿 于 30-5-2006 10:47 AM 发表


我也没强逼你贴出来... 只是贴出来能让大家更明白错误的地方... 也能对症下药... 我也只是只是想更早帮你解决问题...



说真的,真的是没有error code。


我也希望有啊,有error的话我也好做事。
我也不想,像这样大海捞针似的。

所以我就只好把全部的code post出来。

但是到现在我认为可能是我用MySQL的问题。
或是ODBC的问题。

可能迟点我用MSSQL就没有这样多的奇怪的问题了。

但还是要谢谢你们的帮忙
回复

使用道具 举报

发表于 30-5-2006 01:26 PM | 显示全部楼层
无论如何... 你加了parameter了吗??
回复

使用道具 举报

 楼主| 发表于 30-5-2006 11:02 PM | 显示全部楼层
原帖由 小妞儿 于 30-5-2006 01:26 PM 发表
无论如何... 你加了parameter了吗??


结果还是一样没有反应。。。。

也没有error.......



真的没有error请你相信我
要不然没有人要相信我了
回复

使用道具 举报

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

使用道具 举报

发表于 30-5-2006 11:40 PM | 显示全部楼层
原帖由 红发 于 30-5-2006 11:02 PM 发表


结果还是一样没有反应。。。。

也没有error.......



真的没有error请你相信我
要不然没有人要相信我了


不如这样吧... 你是说你的 delete 不能运作, 对吗?
你用 debug trace 把那 sql variable 找出来, 贴在这里... 让我们看看那 sql 究竟有什么在里头...
回复

使用道具 举报

Follow Us
 楼主| 发表于 31-5-2006 01:08 PM | 显示全部楼层
原帖由 小妞儿 于 30-5-2006 11:08 PM 发表
现在把你的整行code贴出来好吗??? 还有... 之前login的page还有问题吗???


我写成这样就没有问题。
login也没有问题。。


  1. '"&request("username")&"'"
复制代码

原帖由 goatstudio 于 30-5-2006 11:40 PM 发表


不如这样吧... 你是说你的 delete 不能运作, 对吗?
你用 debug trace 把那 sql variable 找出来, 贴在这里... 让我们看看那 sql 究竟有什么在里头...


这个要如何做??

不是我的delete不能
是我不能用@uname
只要我改成

  1. '"&request("username")&"'"
复制代码

就没有问题了。。。。。
回复

使用道具 举报

发表于 1-6-2006 12:47 AM | 显示全部楼层
原帖由 红发 于 31-5-2006 01:08 PM 发表

'"&request("username")&"'"


你的username是从username textbox拿来的???
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 1-6-2006 10:36 PM | 显示全部楼层
原帖由 小妞儿 于 1-6-2006 12:47 AM 发表


你的username是从username textbox拿来的???


对的,我是这样写

  1. <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
  1. 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,知道了
要这样

  1. <%@ Import NameSpace="System.Data" %>
  2. <%@ Import NameSpace="system.Data.odbc" %>
  3. <%@ Page Language="vb" Debug="true" trace="true" %>

  4. <script language="vb" runat="server">

  5. Sub My_click(Sender As Object,E As EventArgs)

  6.         Dim Conn As String = ConfigurationManager.ConnectionStrings("Connstri").ConnectionString
  7.         Dim dbcon As New OdbcConnection(Conn)
  8.        
  9.         Dim uname As String = Replace(Trim(username.Text), "'", "''")
  10.         Dim pwd As String = Replace(Trim(password.Text), "'", "''")
  11.        
  12.         Dim sql As String = "SELECT pass FROM usertable WHERE username = ?"
  13.        
  14.         Dim cmd As New OdbcCommand(sql, dbcon)
  15.        
  16.         dbcon.open()
  17.        
  18.         Dim param As New OdbcParameter
  19.        
  20.         param = cmd.Parameters.Add("", OdbcType.VarChar, 50)
  21.         param.Direction = ParameterDirection.Input
  22.         param.Value = uname
  23.        
  24.         Response.write(param)
  25.        
  26.         Dim dr As OdbcDataReader = cmd.ExecuteReader()     
  27.        
  28.                 If dr.Read() Then     
  29.        
  30.                         If Trim(dr("pass")) = pwd Then         
  31.                                 FormsAuthentication.SetAuthCookie(uname, False)               
  32.                                 FormsAuthentication.RedirectFromLoginPage(uname, False)  
  33.                                 Response.Redirect("xx.html")           
  34.                         Else                 
  35.                                 lblAlert.Text = "Wrong password"         
  36.                         End If
  37.                
  38.                 Else     
  39.                         lblAlert.Text = "Wrong Username"        
  40.                 End If

  41.         dr.close()
  42.         dbcon.close()
  43.        
  44.        
  45.         Response.write(uname)
  46.         Response.write("<br>")
  47.         Response.write(pwd)
  48. End Sub

  49. </script>

  50. <html>
  51. <head>
  52. <meta http-equiv="Content-Language" content="en-us">
  53. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  54. <title>Login</title>
  55. </head>
  56. <body>
  57. <form runat="server">
  58. <table border="0" width="100%" cellspacing="0" cellpadding="0" id="table1">
  59.         <tr>
  60.                 <td width="104">&nbsp;</td>
  61.                 <td><asp:Label ID="lblAlert" Runat="server" Text="Please Key In Username And Password"/></td>
  62.         </tr>
  63.         <tr>
  64.                 <td width="104">username</td>
  65.                 <td><asp:TextBox ID="username" Runat="server" Columns="20"/></td>
  66.         </tr>
  67.         <tr>
  68.                 <td width="104">password</td>
  69.                 <td><asp:TextBox ID="password" Runat="server" Columns="20"/></td>
  70.         </tr>
  71.         <tr>
  72.                 <td colspan="2"><asp:Button id="My" runat="server" OnClick="My_click" Text="Login"/>
  73.         </td>
  74.         </tr>
  75. </table>
  76. </form>
  77. </body>
  78. </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的写法...
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 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 发表

....

所以说帮人不是没有好处的。。。
还是可以学到一些奇怪的东西。。 ...


不客气...

但我帮人不是为了好处... 哈哈...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 5-8-2025 03:54 AM , Processed in 0.108685 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表