Click here to Skip to main content
15,915,319 members
Home / Discussions / C#
   

C#

 
GeneralRe: Smart device authentification problem Pin
Tunisien8613-Apr-10 11:09
Tunisien8613-Apr-10 11:09 
GeneralRe: Smart device authentification problem Pin
Luc Pattyn13-Apr-10 11:17
sitebuilderLuc Pattyn13-Apr-10 11:17 
GeneralRe: Smart device authentification problem Pin
Tunisien8613-Apr-10 11:23
Tunisien8613-Apr-10 11:23 
GeneralRe: Smart device authentification problem Pin
Luc Pattyn13-Apr-10 11:35
sitebuilderLuc Pattyn13-Apr-10 11:35 
GeneralRe: Smart device authentification problem Pin
Tunisien8613-Apr-10 11:47
Tunisien8613-Apr-10 11:47 
AnswerRe: Smart device authentification problem Pin
William Winner13-Apr-10 13:31
William Winner13-Apr-10 13:31 
GeneralRe: Smart device authentification problem Pin
Tunisien8614-Apr-10 2:32
Tunisien8614-Apr-10 2:32 
GeneralRe: Smart device authentification problem Pin
William Winner14-Apr-10 6:56
William Winner14-Apr-10 6:56 
You're still not understanding the basic concepts. Have a look at the example on this page: SqlCeDataAdapter Class[^]

Here are the steps you need to do...
1. Create the Connection
2. Create the command and sql string that will extract the data
3. Add the parameter values to the command
4. Create the adapter using the command
5. Fill the dataset

The errors you get are self-explanatory...you created variables that you never assign anything to or use in any way.

You also created a sql string with parameters in it, but then never filled the parameters, so you're never going to return what you want.

With your code...you would want to follow the steps:
C#
//Create the connection
string chcc= "Data Source = BaseGmaoLocale.sdf;";
SqlCeConnection sqlceconn= new SqlCeConnection(chcc);

//Create the command
SqlCeCommand command = sqlceconn.CreateCommand();
command.CommandText = "Select login from Connexion where login=@login and MotPass=@MotPass ";

//Add the parameters
string s1; //store the login name here YOU MUST FILL THIS IN
SqlCeParameter login = new SqlCeParameter("@login", SqlDbType.NVarChar);
login.value = s1;

string s2; //store the password here YOU MUST FILL THIS IN
SqlCeParameter MotPass = new SqlCeParameter("@MotPass", SqlDbType.NVarChar);
MotPass.value = s2;

command.Parameters.Add(login);
command.Parameters.Add(MotPass);

//Create the adapter
SqlCeDataAdapter adapter = new SqlCeDataAdapter(command);

//Create and fill the dataset
DataSet ds = new DataSet();

try
{
   adapter.Fill(ds, "SQL Temp Table");
}
catch (Exception ex)
{
   MessageBox.Show(ex.Message);
}
if ((ds.Tables.Count > 0) && (ds.Tables["SQL Temp Table"] != null))
    MessageBox.Show("Number of row(s) - " + ds.Tables["SQL Temp Table"].Rows.Count);

adapter.Dispose();
sqlceconn.Dispose();
command.Dispose();


if that doesn't work, tell me what the exception message is specifically...and don't change anything that I've written...try it as is filling in the login and password information.

And you only need to put the specific line that could throw an error in the Try/Catch block. In this case, nothing should throw an error until the adapter.Fill call.
AnswerRe: Smart device authentification problem Pin
William Winner14-Apr-10 7:12
William Winner14-Apr-10 7:12 
GeneralRe: Smart device authentification problem Pin
Tunisien8614-Apr-10 10:23
Tunisien8614-Apr-10 10:23 
GeneralRe: Smart device authentification problem Pin
William Winner14-Apr-10 10:48
William Winner14-Apr-10 10:48 
GeneralRe: Smart device authentification problem Pin
Tunisien8614-Apr-10 13:01
Tunisien8614-Apr-10 13:01 
AnswerRe: Smart device authentification problem Pin
Tunisien8619-Apr-10 23:00
Tunisien8619-Apr-10 23:00 
QuestionWriting Assembly Attributes Programmatically Pin
Nadia Monalisa13-Apr-10 10:26
Nadia Monalisa13-Apr-10 10:26 
AnswerRe: Writing Assembly Attributes Programmatically Pin
Martin Jarvis13-Apr-10 10:32
Martin Jarvis13-Apr-10 10:32 
AnswerRe: Writing Assembly Attributes Programmatically Pin
Paw Jershauge13-Apr-10 10:41
Paw Jershauge13-Apr-10 10:41 
GeneralRe: Writing Assembly Attributes Programmatically Pin
Nadia Monalisa13-Apr-10 11:00
Nadia Monalisa13-Apr-10 11:00 
GeneralRe: Writing Assembly Attributes Programmatically Pin
PIEBALDconsult13-Apr-10 11:17
mvePIEBALDconsult13-Apr-10 11:17 
GeneralRe: Writing Assembly Attributes Programmatically Pin
Nadia Monalisa13-Apr-10 11:46
Nadia Monalisa13-Apr-10 11:46 
GeneralRe: Writing Assembly Attributes Programmatically Pin
Luc Pattyn13-Apr-10 13:16
sitebuilderLuc Pattyn13-Apr-10 13:16 
GeneralRe: Writing Assembly Attributes Programmatically Pin
PIEBALDconsult13-Apr-10 13:36
mvePIEBALDconsult13-Apr-10 13:36 
GeneralRe: Writing Assembly Attributes Programmatically Pin
Luc Pattyn13-Apr-10 13:41
sitebuilderLuc Pattyn13-Apr-10 13:41 
GeneralRe: Writing Assembly Attributes Programmatically Pin
PIEBALDconsult13-Apr-10 13:47
mvePIEBALDconsult13-Apr-10 13:47 
QuestionPrint images with the correct size Pin
Eagle3213-Apr-10 9:33
Eagle3213-Apr-10 9:33 
AnswerRe: Print images with the correct size Pin
Alan Balkany14-Apr-10 3:57
Alan Balkany14-Apr-10 3:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.