PDA

View Full Version : syntax error in form clause یعنی چه شه؟



ebtekar
پنج شنبه 20 دی 1386, 22:12 عصر
من می خوام یه دو تا فیلد رو از بانکم بخونم بعد ببینم اگه با هم مطابقت داشت بره به فرم بعدی تا اینجا درسته ولی وقتی می خواد


sRead = sCommand.ExecuteReader();

اجرا بشه این خطا رو میده syntax error in form clause اعصاب منو بهم ریخته راهنماییم کنید کدی رو که استفاده کردم رو به طور کامل براتون گذاشتم



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Waranty
{
publicpartialclasspassword : Form
{
int loginattempts;
publicstring username = "";
publicstring pasword = "";
privateOleDbDataReader sRead;
public password()
{
InitializeComponent();
}

privatevoid password_Load(object sender, EventArgs e)
{

}
privatevoid button1_Click(object sender, EventArgs e)
{
// make sure that the user has input some text
// into the textbox
if (textBox1.Text == "")
{
MessageBox.Show("لطفاً نام کاربری را وارد کنید", "هشدار");
}
else
{
// set the SQL connection string
string sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Application.StartupPath + "/backup/wbanck.mdb" + ";Persist Security Info=False";

// create and initialize the SQL connection
OleDbConnection sConnector =newOleDbConnection(sConnString);

// create the SQL statement
string sSQL = "SELECT * FROM user WHERE username = '" + textBox1.Text + "'";
// create and initialize the SQL command
OleDbCommand sCommand = newOleDbCommand(sSQL, sConnector);

try
{
// set the wait cursor while the query is executed
this.Cursor = Cursors.WaitCursor;
// open SQL connection
sConnector.Open();

// execute the reader using the sSQL statement
sRead = sCommand.ExecuteReader();

while (sRead.Read())
{
// set the variables to their repsective values from sRead
username = sRead.GetValue(0).ToString();
pasword = sRead.GetValue(1).ToString();


}
// per microsoft, close the SQL connection when finished
sConnector.Close();
// set the cursor back to its default
this.Cursor = Cursors.Default;

// checks the returned userid to see if it is empty
if (username == "")
{
MessageBox.Show("کاربری با این نام پیدا نشد");
}
else
// check the returned password against what the user
// has input into the txtPassword textbox
if (textBox2.Text == pasword)
{
this.Hide();
// show frmMain
mainform frmmainform = newmainform();
frmmainform.Show();
}
else
{
// if login fails, increase by 1
loginattempts++;

// if login fails X ammount of times, close the form. If less
// than X, show message box denying access.
if (loginattempts >= 3)
{
MessageBox.Show("سه بار شما کلمه عبور را اشتباه وارد کردید از برنامه خارج می شوید", "هشدار");
this.Close();
}
else
{
MessageBox.Show("دسترسی ندارید", "هشدار");
textBox2.Text = "";

}
}
}

catch (Exception exc)
{
MessageBox.Show(exc.Message, "Exception");
this.Cursor = Cursors.Default;

}
}
}
}
}

choobin84
پنج شنبه 20 دی 1386, 22:47 عصر
string sSQL = "SELECT * FROM user WHERE username = '" + textBox1.Text + "'";
// create and initialize the SQL command

از کلمه کلیدی user و username استفاده کرده اید.
یه نگاه هم به فیلد های جدول بیاندازید و اسم اون فیلد ها رو هم تغییر بدید

SeyedMoosavi
جمعه 21 دی 1386, 00:13 صبح
سلام همونطور که دوست عزیزمون گفتند شما از کلمات کلیدی استفتده کردین بعضی از کلمه ها مثل USER , Name و... رو نمی شه استفاده کرد

ebtekar
جمعه 21 دی 1386, 10:20 صبح
مرسی از لطف شما مشکلم حل شد