Hola a todos de nuevo:
Ante todo agradeceros la rapidez con la que me habéis respondido.
Ahora vamos al tema que nos acontece que creo que estoy cometiendo un error de base.
Lo primero que os voy a decir es que es asp.net 2.0 con visual Studio 2005.
Empiezo otra vez. Tengo un dataset llamado users.vxd que contiene una serie de tableadapters. Los tableadapters son muy sencillos, por ejemplo:
Find(usr)
Select * from users where unick = @unick;
Una vez echo esto pasamos a el código que no puedo entender:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using UsersTableAdapters;
public class CLUsers
{
private USERSTableAdapter _USERSAdapter = null;
protected USERSTableAdapter Adapter
{
get {
if (_USERSAdapter == null)
_USERSAdapter = new USERSTableAdapter();
return _USERSAdapter;
}
}
[System.ComponentModel.DataObjectMethodAttribute(Sy stem.ComponentModel.DataObjectMethodType.Select, true)]
public Users.USERSDataTable GetData()
{
return Adapter.GetData();
}
[System.ComponentModel.DataObjectMethodAttribute(Sy stem.ComponentModel.DataObjectMethodType.Insert, true)]
public int Add(string unick, string name, string sname, string pwd, string question, string answer, string email, string dob)
{
// int error = 0; //if during the proces there is an error it will be swithced to 1.
DateTime dtdob;
CLUsers Aux = new CLUsers();
// VALIDATION:
// if the nick exists (is the key of the table).
if (Adapter.find(unick).Value != 0)
//error 9 the nick name exists.
return (9);
else
{
// all the data introduced is validate and converted.
if (unick.Length > 20 || unick.Length == 0)
{
//error 1: check your nick.
return (1);
}
else
{
if (name.Length > 20 || name.Length == 0)
{
//error 2: check your name.
return (2);
}
else
{
if (sname.Length > 20 || sname.Length == 0)
{
//error 3: check your surename.
return (3);
}
else
{
if (pwd.Length > 20 || pwd.Length == 0)
{
//error 4: check your pasword.
return (4);
}
else
{
if (question.Length > 30 || question.Length == 0)
{
//error 5: check your question.
return (5);
}
else
{
if (answer.Length > 30 || answer.Length == 0)
{
//error 6: check your answer.
return (6);
}
else
{
if (email.Length > 30 || email.Length == 0)
{
//error 7: check your email.
return (7);
}
else
{
try
{
dtdob = Convert.ToDateTime(dob);
}
catch
{
//error 8: check your dob.
return (8);
}
}
}
}
}
}
}
}
try
{
Adapter.Add(unick, name, sname, pwd, question, answer, email, "no", dtdob, 0, DateTime.Today);
}
catch
{
return (10);
//insert in the log one line
}
//ok...
return (0);
}
}
[System.ComponentModel.DataObjectMethodAttribute(Sy stem.ComponentModel.DataObjectMethodType.Insert, true)]
public int getname(string unick)
{
return (Adapter.find(unick).??????);
}
}
El problema radica en los interrogantes… se supone que tendría que ser un código tal que:
Adapter.find(unick).rows(1).(“name”)
Pero no funciona. La verdad es que e realizado muchísimas pruebas y no e dado con la solución.
Espero que lo encendáis y muchas gracias por vuestro tiempo. |