This is my code, i have a error in no value given for one or more required parameters, please kindly solve these problem, help me
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace testsearch
{
public partial class Form1 : Form
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\ARUNKUMAR\\myproject\\myprojects\\data\\as.accdb");
OleDbCommand com;
string str;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str = "select * from purmonth where cusid =" + textBox1.Text;
com = new OleDbCommand(str, con);
DataSet vds = new DataSet();
OleDbDataAdapter vda = new OleDbDataAdapter(com);
vda.Fill(vds, "res");
dataGridView1.DataSource = vds.Tables["res"];
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
con.Open();
}
}
}
Thanking you
Loading
SenthilkumarPosted Apr 21, 2012, 5:00 AM
The problem is clear. You are trying to retrieve the value from the table based on the value given in text box.
Hope this will help you.
Amit DhaniaPosted Apr 21, 2012, 4:09 AM
com.CommandType = CommandType.StoredProcedure;
com.CommandType = CommandType.Text;
Hoping it will resolve your issue.
Datta KharadPosted Apr 21, 2012, 4:03 AM
If datatype of cusid is varchar (string) then you can try this line....otherwise please describe your problem in detail.
string str = "select * from purmonth where cusid = '"+ textBox1.Text+"' ";