Click here to Skip to main content
15,887,585 members
Home / Discussions / C#
   

C#

 
QuestionDifference Between BeginGetResponse and GetResponse Pin
baranils29-Jul-12 9:48
baranils29-Jul-12 9:48 
AnswerRe: Difference Between BeginGetResponse and GetResponse Pin
Richard Andrew x6429-Jul-12 11:17
professionalRichard Andrew x6429-Jul-12 11:17 
AnswerRe: Difference Between BeginGetResponse and GetResponse Pin
Trak4Net29-Jul-12 12:01
Trak4Net29-Jul-12 12:01 
GeneralRe: Difference Between BeginGetResponse and GetResponse Pin
baranils29-Jul-12 19:02
baranils29-Jul-12 19:02 
GeneralRe: Difference Between BeginGetResponse and GetResponse Pin
Trak4Net29-Jul-12 20:28
Trak4Net29-Jul-12 20:28 
GeneralRe: Difference Between BeginGetResponse and GetResponse Pin
baranils29-Jul-12 20:38
baranils29-Jul-12 20:38 
GeneralRe: Difference Between BeginGetResponse and GetResponse Pin
Trak4Net29-Jul-12 21:11
Trak4Net29-Jul-12 21:11 
QuestionDynamically Insert single record into MS access from SQL server Pin
Member 928738129-Jul-12 6:39
Member 928738129-Jul-12 6:39 
Hi ALL,

I have two databases(SQlserver and MS Access) with same schemas (same tables). SQL server database has data but Access has no data (blank database).

My goal : when user enters a ClientId and click insert button then I need to retrive that single record from all tables in sql server database and insert into tables in MS Access Database.

Achieved: i retrived from all tables in sql server databases with client id and stored the data in Dataset.

Problem: Insert into Access tables????

i have table array and i am looping thru all tables in array and trying to insert data from above dataset into Ms Access dynamically.

Can you suggest how insert into Access for all tables dynamically in loop . i cannot wrie insert statement for each table. i need one which is generic for every table so that i will pass parametrs. Its not a bulk insert, its single record push into multiple tables.

-------This is My code-------------------------------------------------------

private void InsertMsiClientIntoTest(string ClientId)
{
SqlConnection sqlConnection = null;
SqlDataAdapter sqlDataAdapter = null;
DataSet sqlserverDataset = new DataSet();
sqlserverDataset.Tables.Add();
sqlConnection = new SqlConnection();
sqlConnection = new SqlConnection("Data Source=THINK;Initial Catalog=" + dbName + ";Integrated Security=True;");
sqlConnection.Open();
sqlDataAdapter = new SqlDataAdapter(ClientSQL.PopulateTables, sqlConnection);
sqlDataAdapter.SelectCommand.Parameters.AddWithValue("@ClientId", cmbId.Text);
sqlDataAdapter.Fill(sqlserverDataset);
GetDataFromTablesForID(sqlserverDataset);
InsertAllTableDataIntoAccess(sqlserverDataset,tableArray);
}


private DataSet GetDataFromTablesForID(DataSet dsTablesList)
{
SqlConnection sqlConnection = null;
SqlDataAdapter sqlDataAdapter = null;
string tableName = string.Empty;
string QueryText = string.Empty;
int i =0;
tableArray = new string[dsTablesList.Tables[0].Rows.Count];
DataSet sqlserverDataset = new DataSet();
sqlserverDataset.Tables.Add();
sqlConnection = new SqlConnection();
sqlConnection = new SqlConnection("Data Source=THINK;Initial Catalog=" + dbName + ";Integrated Security=True;");
sqlConnection.Open();
foreach (DataRow itemRow in dsTablesList.Tables[0].Rows)
{
tableArray[i] = itemRow[0].ToString();
i++;
}
foreach (string tableItem in tableArray)
{
tableName = tableItem;

QueryText = "select x.* from" + " " + tableName + " " +
"x inner join ClientMajor ci on ci.ClientId = x.ClientId where ci.MajorClientId =@ClientId";
}
sqlDataAdapter = new SqlDataAdapter(QueryText, sqlConnection);
sqlDataAdapter.SelectCommand.Parameters.AddWithValue("@ClientId", cmbExceedId.Text);
sqlDataAdapter.Fill(sqlserverDataset);
}

return sqlserverDataset;

}

private void InsertAllTableDataIntoAccess(DataSet Inputset, string[] tableArray)
{
string connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["mdb"].ToString();
OleDbConnection oledbConnection = null;
OleDbDataAdapter oledbDataAdapter = null;
DataSet resultSet = new DataSet();
oledbConnection = new OleDbConnection(connectionstring);
oledbConnection.Open();
foreach (string tableItem in tableArray)
{
//????????? I NEED THE FOLLOWING CODE......////////////???????
oledbDataAdapter.InsertCommand.CommandText="insert into "
oledbDataAdapter.Fill(resultSet.Tables[0]);
}
}

Thanks in Advance...
AnswerRe: Dynamically Insert single record into MS access from SQL server Pin
Trak4Net29-Jul-12 12:09
Trak4Net29-Jul-12 12:09 
AnswerRe: Dynamically Insert single record into MS access from SQL server Pin
BobJanova29-Jul-12 23:31
BobJanova29-Jul-12 23:31 
GeneralRe: Dynamically Insert single record into MS access from SQL server Pin
PIEBALDconsult30-Jul-12 3:47
mvePIEBALDconsult30-Jul-12 3:47 
Questiondata transfer Pin
rizaaltinok29-Jul-12 0:20
rizaaltinok29-Jul-12 0:20 
GeneralRe: data transfer Pin
Abhinav S29-Jul-12 0:27
Abhinav S29-Jul-12 0:27 
GeneralRe: data transfer Pin
BillWoodruff29-Jul-12 19:04
professionalBillWoodruff29-Jul-12 19:04 
AnswerRe: data transfer Pin
Dave Kreskowiak29-Jul-12 3:40
mveDave Kreskowiak29-Jul-12 3:40 
GeneralRe: data transfer Pin
BillWoodruff29-Jul-12 18:19
professionalBillWoodruff29-Jul-12 18:19 
GeneralRe: data transfer Pin
Abhinav S29-Jul-12 22:39
Abhinav S29-Jul-12 22:39 
GeneralRe: data transfer Pin
Dave Kreskowiak30-Jul-12 2:16
mveDave Kreskowiak30-Jul-12 2:16 
Questionbmp & gif convert to led dot matrix display with c# Pin
hosseinzpp28-Jul-12 21:27
hosseinzpp28-Jul-12 21:27 
AnswerRe: bmp & gif convert to led dot matrix display with c# Pin
OriginalGriff28-Jul-12 21:58
mveOriginalGriff28-Jul-12 21:58 
AnswerRe: bmp & gif convert to led dot matrix display with c# Pin
Abhinav S28-Jul-12 22:20
Abhinav S28-Jul-12 22:20 
AnswerRe: bmp & gif convert to led dot matrix display with c# Pin
Dave Kreskowiak29-Jul-12 3:38
mveDave Kreskowiak29-Jul-12 3:38 
GeneralRe: bmp & gif convert to led dot matrix display with c# Pin
yoaz30-Jul-12 5:06
yoaz30-Jul-12 5:06 
GeneralRe: bmp & gif convert to led dot matrix display with c# Pin
Pete O'Hanlon30-Jul-12 5:36
mvePete O'Hanlon30-Jul-12 5:36 
GeneralRe: bmp & gif convert to led dot matrix display with c# Pin
Dave Kreskowiak30-Jul-12 8:18
mveDave Kreskowiak30-Jul-12 8:18 

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.