hi,
I have a form that needs to update a Db. It is almost identical to another form (working o.k)
doing more or less the same thing
and yet here I get the following error msg:
No value given for one or more required parameters
Line 95: atmovies NewmovTbl=new atmovies();
Line 96: NewmovTbl.moviesconn.Open();
Line 97: NewmovTbl.moviesadp.Fill(MoviesDS);
Line 98:
Line 99: DataTable MovTable = MoviesDS.Tables["tblmovie"];
I really can't see why it doesn't work.
Based on my other form it should work.
If u could point me to any mistakes
I'll apreciate it. thanks.
here is the code:
Code:private static string sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Mode=ReadWrite; User ID=Admin; Data Source=C:\\Inetpub\\wwwroot\\DB\\db.mdb;"; private void Page_Load(object sender, System.EventArgs e) { LoadMovDG(); } private void LoadMovDG() { DataSet ds = GetAllMovies(); MovDG.DataSource = ds.Tables[0].DefaultView; MovDG.DataBind(); } private void MovAddBtn_Click(object sender, System.EventArgs e) { AddMovie(this.TBName.Text,this.TBCat.Text,this.TBPrice.Text); } private void AddMovie(string name,string cat, string price ) { string sql = "insert into tblmovie movie_name,movie_categoria,movie_price) "+" values ('{0}', '{1}','{2}') "; sql = String.Format(sql,name,cat,price); UpdateDB(sql); LoadMovDG(); } private void UpdateDB(string cmd) { if(TBName.Text!=null && TBCat.Text!=null && TBPrice.Text!=null ) { DataSet MoviesDS =new DataSet(); atmovies NewmovTbl=new atmovies(); NewmovTbl.moviesconn.Open(); NewmovTbl.moviesadp.Fill(MoviesDS); DataTable MovTable = MoviesDS.Tables["tblmovie"]; DataRow CurrentMovie = FindMovie (MoviesDS,TBName.Text); if (CurrentMovie==null) { try { OleDbConnection connection = new OleDbConnection(sConn); connection.Open(); OleDbCommand command = new OleDbCommand(); command.Connection = connection; command.CommandText = cmd; command.ExecuteNonQuery(); connection.Close(); } catch(Exception x) { status.Text = x.ToString(); status.Visible=true; status.Text="error"; } } else { status.Visible=true; status.Text="movie allready exists"; } NewmovTbl.moviesconn.Close(); } } private DataRow FindMovie(DataSet MovDs, string MovName) { DataTable MovTable = MovDs.Tables["tblmovie"]; foreach (DataRow movie in MovTable.Rows) { string MName = (string)movie["movie_name"]; if (MName == MovName) { movie1=movie; return movie1; } } return null; } public static DataSet GetDataSet(string sql) { DataSet ds = new DataSet(); OleDbConnection oConn = new OleDbConnection(); oConn.ConnectionString = sConn; oConn.Open(); OleDbCommand cmd = new OleDbCommand(sql,oConn); OleDbDataAdapter da = new OleDbDataAdapter(cmd); da.Fill(ds); oConn.Close(); return ds; } public static DataSet GetAllMovies() { string Ctxt = "SELECT movie_code AS Code,movie_name AS Movie,movie_price AS Price FROM tblmovie"; DataSet ds = GetDataSet(Ctxt); return ds; } } }



LinkBack URL
About LinkBacks


