Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How represent CROSS JOIN load form when add combo national table

Status
Not open for further replies.

ahm1985

Programmer
Dec 6, 2012
138
EG
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();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top