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
santhosh s samaka
NA
6
3.7k
what is syntax error in insert query
Jul 31 2010 1:04 AM
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;
using System.Data.Odbc;
namespace Username
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" && textBox2.Text == "" && textBox3.Text == "")
MessageBox.Show("Plz Specify the UserName & Password","ERROR",MessageBoxButtons.OKCancel,MessageBoxIcon.Error);
else if (textBox2.Text == "" && textBox3.Text == "")
MessageBox.Show("Plz Specify the Password", "ERROR", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
else if (textBox3.Text == "")
MessageBox.Show("Plz RE Enter the Password", "ERROR", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
else
{
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Samples\\login.mdb";
String uname, pass;
uname = textBox1.Text;
//System.Windows.Forms.MessageBox.Show(uname);
pass = textBox2.Text;
OleDbConnection myConnection = new OleDbConnection(connectionString);
myConnection.Open();
int i=107;
String query = "insert into LOGIN_TABLE (UserName, Password) VALUES ('" + textBox1.Text.ToString() + "','" + textBox2.Text.ToString() + "')";
//string query = "insert into LOGIN_TABLE (ID,UserName,Password) VALUES (118,'" + textBox1.Text.ToString() + "','" + textBox2.Text.ToString() + "')";
i++;
OleDbCommand myCommand = new OleDbCommand();
myCommand.CommandText = query;
myCommand.Connection = myConnection;
myCommand.ExecuteNonQuery();
myConnection.Close();
System.Windows.Forms.MessageBox.Show("User Account Successfully Created", "Caption", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
}
}
}
Reply
Answers (
2
)
Learning C# step by step "Videos from Microssoft"
How to draw lines from vertices (x,y) (which i stored the value in arraylist) in c#