实现自定义配置文件提供程序的最简单方法 [英] Simplest Method to Implement a Custom Profile Provider

查看:59
本文介绍了实现自定义配置文件提供程序的最简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我知道这已在多个帖子中讨论过了。但是,我还没有看到一个很好的例子。


也就是说,我有一个使用ASP.NET 2.0控件的自定义成员资格提供程序。我被限制使用一个exsing SQL 2000数据库,它适用于基本字段(用户名,密码,电子邮件等)。但是,我需要添加更多信息(电话号码,年龄等)。


在阅读现有讨论时,我可以看到将此信息存储在配置文件中的正当理由。我已下载并尝试使用MS Access Provider示例,但收效甚微(可能因为它在C中,我只知道VB)。我正在努力使基础工作起作用,例如定义存储配置文件信息的位置(配置文件提供程序?)以及如何正确地将现有成员资格数据与此新配置文件数据相关联。我想我应该通过UserID或类似的东西链接它,但我无法通过代码弄清楚如何做到这一点。


如果有人能给我任何信息我会非常感激指导如何执行此操作或其他任何可能对我有帮助的VB特定示例。谢谢!

OK, I know this has been discussed in multiple posts. However, I still have not seen a good example.

That is, I have a custom Membership provider using the ASP.NET 2.0 controls. I am restricted to using an exising SQL 2000 database, which works for the basic fields (username, pw, email, etc). However, I need to add more information (phone number, age, etc).

In reading the existing discussions, I can see the valid reasons for storing this information in a profile. I have downloaded and tried to use the MS Access Provider sample, with little success (probably because it is in C, and I only really know VB). I am struggling to get the basics working, such as defining a location to store the profile information (profile provider?) and how to correctly associate my existing membership data with this new profile data. I think I should link it via a UserID or something similar, but I am unable to figure out how to do this via code.

I would greatly appreciate it if anyone could give me any guidance to a VB-specific example of how to do this or anything else that might help me. Thank you!

推荐答案

将你带到另一个可能得到更好回复的论坛
moving you to a different forum where you might get a better response



我正在努力使基本工作正常工作,例如定义存储配置文件信息的位置(配置文件提供程序?)以及如何正确地将现有成员资格数据与此新配置文件数据相关联。我想我应该通过UserID或类似的东西链接它,但我无法通过代码弄清楚如何做到这一点。


如果有人能给我任何信息我会非常感激指导如何执行此操作或其他任何可能对我有帮助的VB特定示例。谢谢!
I am struggling to get the basics working, such as defining a location to store the profile information (profile provider?) and how to correctly associate my existing membership data with this new profile data. I think I should link it via a UserID or something similar, but I am unable to figure out how to do this via code.

I would greatly appreciate it if anyone could give me any guidance to a VB-specific example of how to do this or anything else that might help me. Thank you!



如果你可以将它们作为不同的表存储在同一个数据库中,这是最简单的,那么你可以使用你曾经使用的相同语法通过单个关系查询打开它们在你继承的asp文件中。如果这两个表被称为成员,那么和配置文件,以及匹配的字段名称是userID和userID。和memberNum然后查询如下所示:

It''s easiest if you can store them as different tables in the same database, then you can open them with a single relational query using the same syntax you had in the asp file you inherited. If the two tables are called "members" and "profiles", and the field names that match are "userID" and "memberNum" then the query looks like this:

展开 | 选择 | Wrap | 行号


jhardman,


首先关闭, 非常感谢您的回复。你帮助清理了如何设置&查询数据库中的表。但是,我需要在前端(VB / ASP.NET)部分提供更多帮助。


据我所知,我必须定义一个配置文件提供程序,然后添加字段配置文件将包含。我将这些添加到我的web.config文件中,该文件有效(即没有错误)。但我仍然无法访问代码中的配置文件的字段。我见过一些例子,他们做了类似
jhardman,

First off, Thank You very much for your reply. You helped clear up how to setup & query the tables in the database. However, I need more help on the front-end (VB/ASP.NET) portion.

As I understand it, I have to define a profile provider and then add the fields that the profile will contain. I added these to my web.config file, which worked (that is, no errors). But I still could not access the fields of the profile in my code. I have seen examples where they did something like
profile.Age =" 23"

profile.Zip =" 34243"
profile.Age = "23"
profile.Zip = "34243"

并选择了VS中的intellisense这些在我下载的演示项目中。在我的项目中,我一直遇到错误& intellisense没有功能 - 就好像web.config文件中的引用不存在一样。我现在不在我的开发机器上,因此我无法准确地给出我的代码现在的样子 - 如果发布它有助于调试,请让我知道&我将重新发布。


我一直很难找到一个演练或示例,其中有人为一个exising(或全新)项目添加了一个配置文件提供程序。我非常感谢您能给我的任何其他指导或信息。


再次感谢您。

And the intellisense in VS picked these up in the demo projects I downloaded. In my project I kept getting errors & intellisense didn''t function - as if the references in the web.config file did not exist. I am not on my development machine right now, so I can''t give an exact post of what my code looks like right now - if posting it would help debug, please let me know & I will repost.

I have been having a hard time finding a walkthrough or example where someone added a profile provider to an exising (or brand-new) project. I would GREATLY appreciate any additional guidance or information you could give me.

Thank you again.


这篇关于实现自定义配置文件提供程序的最简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆