dataset ds= new dataset();--type was not found..error

Posted by Jayakumarkm under WPF on 3/30/2010 | Views : 4593 | Status : [Member] | Replies : 3
public SqlConnection conn= new SqlConnection("Data Source=;Initial Catalog=;Integrated Security=SSPI;UserID=sa;Password=;"); ;
public SqlCommand com;
string strSql = "SELECT * FROM SahanaMusical";
conn.Open();
com = new SqlCommand(strSql, conn);
SqlDataAdapter da = new SqlDataAdapter(com);

DataSet ds12 = new DataSet();

da.Fill(ds12, "SahanaMusical");
dataGrid4.DataContext = ds12;
dataGrid4.ItemsSource = ds12.Tables[0].ToString();
conn.Close();
com.Dispose();




Responses

Posted by: Vuyiswamb on: 3/30/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
i have not used WPF that much , but the code in ado.net should not change

try this
 


public SqlConnection conn= new SqlConnection("Data Source=;Initial Catalog=;Integrated Security=SSPI;UserID=sa;Password=;");
public SqlCommand com;
string strSql = "SELECT * FROM SahanaMusical";
com = new SqlCommand(strSql, conn);
SqlDataAdapter da = new SqlDataAdapter(com);
DataSet ds12 = new DataSet();
try
{
conn.Open();

da.Fill(ds12);
dataGrid4.Datasource= ds12;
}
catch(sqlException ex)
{
//show your Error message ex.Message();
}
finally
{
conn.Close();
}



Thank you for posting at Dotnetfunda
[Administrator]

Jayakumarkm, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sagarp on: 3/30/2010 [Member] Bronze

Up
0
Down
hi friend

only ref in that link code and u can change on Ur original code


http://xceed.com/CS/forums/thread/19460.aspx 

http://www.codeproject.com/Messages/2932860/ComboBox-plus-2-DataSet-DataTable-ItemSource-and-S.aspx


Thanks
SagarP
http://www.emanonsolutions.net
http://emanonsolutions.blogspot.com/

Jayakumarkm, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sagarp on: 3/30/2010 [Member] Bronze

Up
0
Down
Hi ref

this code


<Button Height="23" Margin="0,12,35,0" Name="button1" VerticalAlignment="Top" HorizontalAlignment="Right" Width="46" Click="button1_Click">Go</Button>


<ListView Name="listView1" Margin="0,41,0,0">

<ListView.View>

<GridView>

<GridViewColumn Header="User_Name" Width="100" DisplayMemberBinding="{Binding Path=User_Name}"/>

<GridViewColumn Header="Project_Name" Width="100" DisplayMemberBinding="{Binding Path=Project_Name}" />

<GridViewColumn Header="CD_Name" Width="100" DisplayMemberBinding="{Binding Path=CD_Name}"/>

<GridViewColumn Header="IsOracle" Width="100" DisplayMemberBinding="{Binding Path=IsOracle}" />

</GridView>

</ListView.View>

</ListView>

</Grid>

</Window>



private void button1_Click(object sender, RoutedEventArgs e)

{

DataSet ds = new DataSet();

string sql = "select * from tblOTRecord order by Project_Name";

ds = ClsDBAccess.mGetOrcDataset(sql, ClsDBAccess.eConn.INTRANET); // Custom method, it is ok, getting rows

if(ds.Tables[0].Rows.Count > 0)

{

Binding bind = new Binding();

listView1.DataContext = ds.Tables[0];

listView1.SetBinding(ListView.ItemsSourceProperty, bind);

}

}


Thanks
SagarP
http://www.emanonsolutions.net
http://emanonsolutions.blogspot.com/

Jayakumarkm, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response