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

Datta KharadRank #2,135 · 668 reputationPosted Apr 21, 2012, 12:03 AM EDT
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+"' ";
Amit DhaniaRank #3,217 · 446 reputationPosted Apr 21, 2012, 12:09 AM EDT
com.CommandType = CommandType.StoredProcedure;
com.CommandType = CommandType.Text;
Hoping it will resolve your issue.
SenthilkumarRank #387 · 6.5K reputationPosted Apr 21, 2012, 1:00 AM EDT
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.