3 Replies - 1231 Views - Last Post: 13 March 2009 - 05:01 AM Rate Topic: -----

#1 soumyasurya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-February 09

How do u access a Database using a C# structure

Posted 13 March 2009 - 03:15 AM

Hi,
I am a beginner in C# and SQL Database 2005.
Let me know how to access a Database and get the data into a C# structures.I dont need the code.i Just need directions.


Thanks in Advance.
Is This A Good Question/Topic? 0
  • +

Replies To: How do u access a Database using a C# structure

#2 ErPriyansh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 12-March 09

Re: How do u access a Database using a C# structure

Posted 13 March 2009 - 03:27 AM

View Postsoumyasurya, on 13 Mar, 2009 - 02:15 AM, said:

Hi,
I am a beginner in C# and SQL Database 2005.
Let me know how to access a Database and get the data into a C# structures.I dont need the code.i Just need directions.


Thanks in Advance.


SqlConnection oConn = new SqlConnection(configurationManager.Connectionstring["Here Put ur Connection string name"].connectionStrings);

SqlCommand oCommd = new SqlCommand("Write any Query",oConn);
oConn.Open();
oCommnd.ExecuteNonQuery();
oConn.Close();

SqlDataAdapter oDA = new SqlDataAdapter(oCommd);
DataTable oDT = new DataTable();
oDA.Fill(oDT);



[How u get connection string? Here r steps....]
1) just make table in MSsql server 2005 and drag & drop on to ur design Page , then open the source , copy connection string name and paste on above..

*** MOD EDIT: Added code tags. Please :code: ***

This post has been edited by JackOfAllTrades: 13 March 2009 - 05:02 AM

Was This Post Helpful? 0
  • +
  • -

#3 soumyasurya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-February 09

Re: How do u access a Database using a C# structure

Posted 13 March 2009 - 03:45 AM

View PostErPriyansh, on 13 Mar, 2009 - 02:27 AM, said:

View Postsoumyasurya, on 13 Mar, 2009 - 02:15 AM, said:

Hi,
I am a beginner in C# and SQL Database 2005.
Let me know how to access a Database and get the data into a C# structures.I dont need the code.i Just need directions.


Thanks in Advance.


SqlConnection oConn = new SqlConnection(configurationManager.Connectionstring["Here Put ur Connection string name"].connectionStrings);

SqlCommand oCommd = new SqlCommand("Write any Query",oConn);
oConn.Open();
oCommnd.ExecuteNonQuery();
oConn.Close();

SqlDataAdapter oDA = new SqlDataAdapter(oCommd);
DataTable oDT = new DataTable();
oDA.Fill(oDT);


[How u get connection string? Here r steps....]
1) just make table in MSsql server 2005 and drag & drop on to ur design Page , then open the source , copy connection string name and paste on above..





Hi,
I am able to coonection to the Database but my problem is how do u get the data from database in a ArrayList.And how do u perform basic updation,deletion and insertion on the Database.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,516
  • Joined: 23-August 08

Re: How do u access a Database using a C# structure

Posted 13 March 2009 - 05:01 AM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1