ahmed sa

ahmed sa

  • NA
  • 289
  • 129k

How represent CROSS JOIN load form when add combo nationali

Feb 6 2014 9:49 AM
Hi guys I have combobox i want to add in to fillcontroll() function but not accept
this is my data
Table driver
Driver ID
Driver Name
Nationality ID
ADDRESS

table nationality
nationality id
nationality name

in load form i want combobox display text is nationality name
and in same time i need to show when navigate record
this is my view in database 
Driver1view
SELECT     dbo.Driver.DriverName, dbo.Driver.Nationality, dbo.Driver.Address, dbo.Driver.NationalityID, dbo.Nationality.NationalityName
FROM         dbo.Driver CROSS JOIN
                      dbo.Nationality

DataTable

DataSet ds = new DataSet();

SqlDataAdapter da = new SqlDataAdapter();

SqlConnection con = new SqlConnection();

private


in form load i write following

this.Cursor = Cursors.WaitCursor;
string constr = "Data Source=" + value1 + ";Initial Catalog=" + value2 + ";User ID=" + value3 + ";Password=" + value4 + "";
con = new SqlConnection(constr);
string comdstr = "select * from Driver1view";
da = new SqlDataAdapter(comdstr, constr);
ds = new DataSet();
dt = new DataTable();

da.Fill(ds,"Driver");
      
dt = ds.Tables["Driver"];
          
 totalrecord = dt.Rows.Count;
this.Cursor = Cursors.Default;              
if (totalrecord > 0)
{

fillcontrol();
                  }
else
{
MessageBox.Show("There is no records");
}

private

{totalrecord = dt.Rows.Count;



}

Now my problem is when I want to show combobox in load form it not show and it give me

errors why






textBox1.Text = dt.Rows[currrecord]["DriverID"].ToString();

textBox2.Text = dt.Rows[currrecord]["DriverName"].ToString();

combobox.text = dt.Rows[currrecord]["NationalityName"].ToString();"

textBox4.Text = dt.Rows[currrecord]["Address"].ToString();"

label6.Text = currrecord+1 + "of"+ totalrecord.ToString();



void fillcontrol()
int currrecord = 0;
private int totalrecord = 0;
dt = new DataTable();

Answers (1)