Jump to content

HELP.!!! Access and C#.!!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
UbuntuX

UbuntuX

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
I work on one to many database on access but I have no idea how I update or retrieve the second table's data from C# I know how to work with single tables or multiple tables but when there is a relationship I am totally screwed ,plz help

I gotta use primary key of first table in second table's second column cause the one to many but u know due to the relationship I can't directly involve with the second table so I wonder is that possible to update the data from first table from C# to second table ,like we normally do in Access manually

:closedeyes::closedeyes::closedeyes:
:mad::mad:

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
If possible, I would strongly encourage you to dump Access. It is a toy, not a database.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
UbuntuX

UbuntuX

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
if u don't know the way to solve that then don't answer

#4
malindesha

malindesha

    Newbie

  • Members
  • Pip
  • 5 posts
create view(query) using related tables and call it from C# that will do

follow this link

Create an Access Query

#5
UbuntuX

UbuntuX

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
thanks for your answer but I have done the same but how would I insert data to Second Tables's foreign key column

#6
UbuntuX

UbuntuX

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
no it doesn't work I can't Update my udatabase cause I use

CommandBuilder with .Update Method it says can't work with multiple tables
is there any alternative way to update database without using CommandBuilder

Edited by UbuntuX, 22 May 2010 - 12:39 PM.


#7
UbuntuX

UbuntuX

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
where are these people .? :crying:

#8
UbuntuX

UbuntuX

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts

WingedPanther said:

If possible, I would strongly encourage you to dump Access. It is a toy, not a database.
alright then tell me at least how it do that with SQL Express but I need codes of C#

#9
BuckAMayzing

BuckAMayzing

    Learning Programmer

  • Members
  • PipPipPip
  • 39 posts
Do you know any SQL syntax? I'm not sure what you're trying to accomplish, but I assume it's something along this lines.

for access:
using System.Data.OdbcClient

class SomeClass
{
       public void someCommand(string someData)
       {
             OdbcConnection conn = new OdbcConnection(***CONNECTION STRING GOES HERE***)
             OdbcCommand updateCommand = conn.CreateCommand();
             updateCommand.CommandText = "update TABLE_TWO set SOMEVAL = @PARAM where TABLE_TWO.PRIMARY_KEY = TABLE_ONE.FOREIGN_KEY";
             updateCommand.Parameters.Add("@PARAM",OdbcDataType.NVarChar,50);
             updateCommand.Parameters["@PARAM"].Value = someData;
             updateCommand.ExecuteNonQuery();
       }
}

For SQL server, just replace Odbc with Sql, and your using directive to:

using System.Data.SqlClient

You'll have to google the connection string for Access, as I don't know it, but I'm with the rest of the guys in that you should dump Access. There's just too much waste for any kind of serious application IMO.