TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Israel
701
1.3k
217.2k
Please what's wrong here???
May 9 2016 7:50 AM
Hi!
Please there's something wrong into this sql query??? I use a MS access data base with a column "
company
" as
text
data type and "
year
" as
text
data type. I need to know if there is something wrong wrinting cote.
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\LunaVisa\Visa\Visa\App_Data\visa.mdb;Persist Security Info=False";
OleDbConnection sqlCon = new OleDbConnection(connectionString);
sqlCon.Open();
string commandString =
"select top 1 * from Bill where company ='" + company.Text + "' and year =" + txtYear.Text + " order by billNumber desc"
;
/
/the bugs message is :
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: incorrect expression.
OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
OleDbDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
txtResFactN.Text = read["numfactura"].ToString(); // it will show your friend's name
//txtMention21.Text = read["codempresa"].ToString(); // it will show your friend's name
}
}
else
{
MessageBox.Show("A ultima numeração " + cbxEmpresa.Text + " não foi encontrada");
}
read.Close();
sqlCon.Close();
Reply
Answers (
4
)
DataGridView Resizing Problem
Using VC++ MFC diaglog to retrieve data from database: