Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Database With Microsoft Visual Studio With C#

database

  • Please log in to reply
20 replies to this topic

#13 percis

percis

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 72 posts
  • Programming Language:C
  • Learning:C#, (Visual) Basic

Posted 27 June 2012 - 12:55 AM

If you just want to execute the code successfully, you can call the DBTest method from your form's Load event handler. But note that you have a have a sql database and you have to change the connection string accordingly.

I'm lost. i really need help in setting up sql database/ any step from the beginning. Im using microsoft visual 2010. could u help me?

could u help me?

could u help me?

i don't have microsoft SQL server. I only have microsoft visual studio professional 2010 installed. would u help me solve the pblm?
  • 0

#14 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 27 June 2012 - 12:57 AM

Do you have Microsoft Access installed on your machine? If yes, I'll change the code accordingly and post the code here.
  • 0

#15 percis

percis

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 72 posts
  • Programming Language:C
  • Learning:C#, (Visual) Basic

Posted 27 June 2012 - 01:02 AM

could u help me?


i don't have microsoft SQL server. I only have microsoft visual studio professional 2010 installed. would u help me solve the pblm?

or do i need to install ms access?

Do you have Microsoft Access installed on your machine? If yes, I'll change the code accordingly and post the code here.

ok i'll install ms access. but how to create the database/table in ms access. i need every detail from the step 1 because i am new to this topic. pls

or do i need to install ms access?

ok i'll install ms access. but how to create the database/table in ms access. i need every detail from the step 1 because i am new to this topic. pls

nw, hw i do i carry out to solve the pblm?
  • 0

#16 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 27 June 2012 - 01:03 AM

Read here about creating database in MS Access.
  • 0

#17 percis

percis

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 72 posts
  • Programming Language:C
  • Learning:C#, (Visual) Basic

Posted 27 June 2012 - 01:25 AM

Read here about creating database in MS Access.

do i have read MS access table too? and how abt e coding to visual studio?
  • 0

#18 percis

percis

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 72 posts
  • Programming Language:C
  • Learning:C#, (Visual) Basic

Posted 27 June 2012 - 01:41 AM

do i have read MS access table too? and how abt e coding to visual studio?

pls reply me . i'm signing out. bye
  • 0

#19 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 27 June 2012 - 02:17 AM

Ok, attachment is the project that contains has the MS-Access implementation of your database. The database file is in the CodeCall\Bin\Debug\Geometry.accdb. And I just changed the adapter and connection class of my solution for SQL database. And here is the changed code --
void DBTest()

{

try

{

System.Data.OleDb.OleDbConnection conn =

new System.Data.OleDb.OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\Geometry.accdb");

conn.Open();

System.Data.OleDb.OleDbDataAdapter adapter =

new System.Data.OleDb.OleDbDataAdapter("SELECT * FROM Rectangles", conn);

System.Data.DataTable table = new System.Data.DataTable();

adapter.Fill(table);

table.Columns.Add("Area");

foreach (System.Data.DataRow row in table.Rows)

{

object[] cells = row.ItemArray;

cells[2] = Convert.ToInt32(cells[0]) * Convert.ToInt32(cells[1]);

row.ItemArray = cells;

}

dataGridView1.DataSource = table;

}

catch (Exception exc)

{

Console.WriteLine("Error: " + exc.Message);

}

}

Attached Files


  • 1

#20 percis

percis

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 72 posts
  • Programming Language:C
  • Learning:C#, (Visual) Basic

Posted 03 July 2012 - 01:19 AM

Cn u help me create a GUI for "solar battery sizing calculator" - MS Visual with C#.
  • 0

#21 papabear

papabear

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 03 July 2012 - 02:50 AM

sorry but we can't give you out all the code.. we can only give hints and some clue or help you get back on track...
if we give you the whole code it's not our lost.. it's yours, because you won't learn...

What you asked is how to compute the area of the rectangle using SQL, the query of Orjan is the answer for that,
if you are still learning things or new to this.. here's a good website for beginners it will cover up database connection and CRUD(Create Retrieve Update Delete) http://www.homeandle...arp/csharp.html

about the sql server you can download the Microsoft SQL server express edition for free and download the MS SQL management express also :)

for the connectionstrings you can go to http://connectionstrings.com

Have fun :)
  • 1
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download