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:
HELP.!!! Access and C#.!!
Started by UbuntuX, May 21 2010 06:31 AM
8 replies to this topic
#1
Posted 21 May 2010 - 06:31 AM
|
|
|
#2
Posted 21 May 2010 - 07:15 AM
If possible, I would strongly encourage you to dump Access. It is a toy, not a database.
#3
Posted 21 May 2010 - 12:01 PM
if u don't know the way to solve that then don't answer
#4
Posted 21 May 2010 - 07:54 PM
create view(query) using related tables and call it from C# that will do
follow this link
Create an Access Query
follow this link
Create an Access Query
#5
Posted 22 May 2010 - 11:56 AM
thanks for your answer but I have done the same but how would I insert data to Second Tables's foreign key column
#6
Posted 22 May 2010 - 12:01 PM
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
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
Posted 22 May 2010 - 03:46 PM
where are these people .? :crying:
#8
Posted 22 May 2010 - 05:34 PM
WingedPanther said:
If possible, I would strongly encourage you to dump Access. It is a toy, not a database.
#9
Posted 23 May 2010 - 05:54 AM
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:
For SQL server, just replace Odbc with Sql, and your using directive to:
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.
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.


Sign In
Create Account


Back to top









