2 Replies - 8646 Views - Last Post: 17 July 2006 - 03:17 AM Rate Topic: -----

#1 suleh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 14-July 06

insert into command

Posted 14 July 2006 - 05:34 AM

when i use insert into command to add records for foxpro tables, i am able to view the same in browse statement. but when i issue filter or condition for browse these records are not displayed. only after issuing reindex option from foxpro these records are display. can anyone help me, how to reindex foxpro files from c#.net
Is This A Good Question/Topic? 0
  • +

Replies To: insert into command

#2 Vegter  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 77
  • Joined: 21-September 05

Re: insert into command

Posted 16 July 2006 - 11:50 PM

View Postsuleh, on 14 Jul, 2006 - 04:26 AM, said:

when i use insert into command to add records for foxpro tables, i am able to view the same in browse statement. but when i issue filter or condition for browse these records are not displayed. only after issuing reindex option from foxpro these records are display. can anyone help me, how to reindex foxpro files from c#.net



Your post is very confusing. Could you supply us with more information on what you are trying to do? And supply us with the code you have written so far? Check the forum rules before posting.
Was This Post Helpful? 0
  • +
  • -

#3 suleh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 14-July 06

Re: insert into command

Posted 17 July 2006 - 03:17 AM

[quote name='Vegter' date='16 Jul, 2006 - 10:42 PM' post='162275']

View Postsuleh, on 14 Jul, 2006 - 04:26 AM, said:

the following code is written in c#.net to update foxpro tables. Insert into command is adding records to foxpro tables. But when condional quiries are given from foxpro command window (browse for billno=<>) these added records are not displaying. Only after issuing reindex from foxpro command window these records are displayed. Can anyone help me how can i reindex these records from c#.net



using System;
using System.Data;
using System.Data.Odbc;
using System.Data.OleDb;
using System.Windows;
using System.Windows.Forms;

namespace atease
{
/// <summary>
/// Summary description for clBilling.
/// </summary>
public class billing
{
OleDbConnection con;
OleDbCommand cmd;

public billing()
{
con= new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + frmMain.ydir + ";Extended Properties=dBASE IV");
}

public float cbo,amount,disc;
public string code,cacr,rep,series,mdt,repname;
public string name,add1,add2,place,osamount;
public DataTable itms;
product prd=new product();

public void save()
{
con.Open();
string stg="insert into salehead (billno,code,amount,cacr,discount,rep,series,osamount,[date]) values(" + cbo + ",'" + code + "'," + amount + ",'" + cacr + "'," + disc + ",'" + rep + "','" + series + "','" + osamount +"','" + mdt + "')";
cmd=new OleDbCommand(stg,con);
try
{
cmd.ExecuteNonQuery();
cmd.Dispose();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

if(code.Length==0 && name.Length>0)
{
stg="insert into salehd1 (billno,name,add2,place) values (" + cbo + ",'" + name + "','" + add2 + "','" + place + "')";
cmd=new OleDbCommand(stg,con);
cmd.ExecuteNonQuery();
cmd.Dispose();
}

for(int i=0;i<itms.Rows.Count;i++)
{
DataRow dr;
dr=itms.Rows[i];
prd.code=dr["code"].ToString();
int pr=prd.findcode();

if( dr["code"].ToString().Length>0 && int.Parse(dr["qty"].ToString())>0 && pr==1)
{
stg="insert into salebill (billno,series,code,rate,qty,disc,lpt,tax) values (" + cbo + ",'" + series + "','" + dr["code"].ToString() + "'," + Double.Parse(dr["rate"].ToString()) + "," + float.Parse(dr["qty"].ToString()) + "," + Double.Parse(dr["disc"].ToString()) + ",'" + prd.lpt + "'," + prd.tax + ")";
cmd=new OleDbCommand(stg,con);
cmd.ExecuteNonQuery();
cmd.Dispose();

stg="update product set sale=" + (prd.sale+float.Parse(dr["qty"].ToString())+" where code='"+ dr["code"].ToString()+"'" ) ;
cmd=new OleDbCommand(stg,con);
cmd.ExecuteNonQuery();
cmd.Dispose();
}
}
con.Close();
}

}

}
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1