Skip to content

How represent CROSS JOIN load form when add combo nationali

ahmed sa

Asked Feb 6, 2014, 4:49 AM EST1 answer
Share
LinkedInX
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

Java
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
SqlConnection con = new SqlConnection();

private


in form load i write following

C#
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






SQL
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();

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi guys what i need here actually is how i represent cross join when retrieve data example when my command is "select * from driver" i know that but when there are more tables how i represnt this and dataadptor.fill(which will assign here)
    0