Click here to Skip to main content
15,923,142 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to validate name with databae table (no space) Pin
Shameel24-Nov-09 23:07
professionalShameel24-Nov-09 23:07 
GeneralRe: how to validate name with databae table (no space) Pin
LTMKH27-Nov-09 15:57
LTMKH27-Nov-09 15:57 
GeneralRe: how to validate name with databae table (no space) Pin
Shameel27-Nov-09 18:54
professionalShameel27-Nov-09 18:54 
GeneralRe: how to validate name with databae table (no space) Pin
LTMKH27-Nov-09 20:33
LTMKH27-Nov-09 20:33 
GeneralRe: how to validate name with databae table (no space) Pin
Shameel27-Nov-09 21:54
professionalShameel27-Nov-09 21:54 
GeneralRe: how to validate name with databae table (no space) Pin
LTMKH30-Nov-09 15:16
LTMKH30-Nov-09 15:16 
GeneralRe: how to validate name with databae table (no space) Pin
LTMKH30-Nov-09 15:18
LTMKH30-Nov-09 15:18 
QuestionC# ADO.net Adapter Update Question. Pin
adamzimmer24-Nov-09 17:00
adamzimmer24-Nov-09 17:00 
I'm new to C# and am trying to access and update a Access Database. I've managed to create the database and can see the results in Access. I'm also able to open the Database and load the tables, but when I try to do an update it does not post back my changes. Below is the code with comments where things seem to fail. I do not get an exception, I just don't see the changes in the database file.


// This method seems to work fine, it loads the data from the database into the six tables.
public void openDatabase(DataSet ds, string filename)
{
// I have 6 tables in the dataset/database.
string[] names = { "Project", "Portfolios", "Equations", "Scenarios", "Reports", "Rules" };
string strAccessConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename;

for (int i = 0; i < names.Length; i++)
{
string strAccessSelect = "SELECT * FROM " + names[i];

try
{
myAccessConn = new OleDbConnection(strAccessConn);
}
catch (Exception ex)
{
Console.WriteLine("Error: Failed to create a database connection. \n{0}", ex.Message);
return;
}

try
{
OleDbCommand myAccessCommand = new OleDbCommand(strAccessSelect, myAccessConn);
myDataAdapter = new OleDbDataAdapter(myAccessCommand);

myAccessConn.Open();
myDataAdapter.Fill(ds, names[i]);
}
catch (Exception ex)
{
Console.WriteLine("Error: Failed to retrieve the required data from the DataBase.\n{0}", ex.Message);
return;
}
finally
{
myAccessConn.Close();
}

}
}

// This is the method I'm having trouble with, I sent the Dataset off to another routine which changes some
// of the datarows, I can see the changes there in the dataset but update does not write them to disk.
public void updateDatabase(DataSet ds)
{
try
{
dw = new DebugWindow(); // This opens up a window to display the dataset
dw.Show();
dw.dumpDataSet(ds); // This dumps the dataset to the window, the dataset looks correct with my changes

myAccessConn.Open(); // I don't think I need to do an open as the update should do this but I'm trying all kinds of things
ds.AcceptChanges(); // Don't think I need this

// This seems to be the line that does not work. I've also tried (ds, "Rules") as well. Ideally, I would
// just pass in the dataset and all the tables would be updated.
myDataAdapter.Update(ds.Tables["Rules"]);
myAccessConn.Close();
}
catch (System.Exception ex)
{
dw.displayMsg("Update Failed" + ex.Message);
}
}
AnswerRe: C# ADO.net Adapter Update Question. Pin
PIEBALDconsult24-Nov-09 18:18
mvePIEBALDconsult24-Nov-09 18:18 
GeneralRe: C# ADO.net Adapter Update Question. Pin
adamzimmer25-Nov-09 4:42
adamzimmer25-Nov-09 4:42 
AnswerRe: C# ADO.net Adapter Update Question. Pin
Mycroft Holmes24-Nov-09 18:52
professionalMycroft Holmes24-Nov-09 18:52 
AnswerRe: C# ADO.net Adapter Update Question. Pin
dxlee25-Nov-09 3:52
dxlee25-Nov-09 3:52 
GeneralRe: C# ADO.net Adapter Update Question. Pin
adamzimmer25-Nov-09 4:52
adamzimmer25-Nov-09 4:52 
QuestionMSMQ Pin
Tiger45624-Nov-09 7:11
Tiger45624-Nov-09 7:11 
AnswerRe: MSMQ Pin
Jimmanuel24-Nov-09 7:31
Jimmanuel24-Nov-09 7:31 
AnswerRe: MSMQ Pin
David Skelly24-Nov-09 22:35
David Skelly24-Nov-09 22:35 
QuestionWindows App Published with Visual Studio 2005 comes up blank Pin
JTRizos24-Nov-09 7:01
JTRizos24-Nov-09 7:01 
QuestionChange Calendar Type of DateTimePicker ? Pin
Mohammad Dayyan24-Nov-09 6:17
Mohammad Dayyan24-Nov-09 6:17 
AnswerRe: Change Calendar Type of DateTimePicker ? Pin
Abhishek Sur24-Nov-09 11:16
professionalAbhishek Sur24-Nov-09 11:16 
QuestionWindows service schedule Pin
Priya Prk24-Nov-09 4:16
Priya Prk24-Nov-09 4:16 
AnswerRe: Windows service schedule Pin
Calla24-Nov-09 4:24
Calla24-Nov-09 4:24 
GeneralRe: Windows service schedule Pin
Priya Prk24-Nov-09 4:29
Priya Prk24-Nov-09 4:29 
GeneralRe: Windows service schedule Pin
PIEBALDconsult24-Nov-09 6:08
mvePIEBALDconsult24-Nov-09 6:08 
AnswerRe: Windows service schedule Pin
PIEBALDconsult24-Nov-09 4:29
mvePIEBALDconsult24-Nov-09 4:29 
AnswerRe: Windows service schedule Pin
Covean24-Nov-09 4:40
Covean24-Nov-09 4:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.