Solved

DataTable Fill

Posted on 2014-04-15
3
203 Views
Last Modified: 2014-04-20
was wondering if my explanation bellow is correct
string SQL = @" insert into User_Activity_Log
            values('" + UserName + "', '" + UserID + "' ,getdate(), '" + action + "' ,'','" + IP + "')";
  SqlConnection con = Main.GetDBConnection();
// Create a connection to SQL Database with intance con

            DataTable consultantTable = new DataTable();
//Create a table in memory called consultantTable

            SqlDataAdapter Consultantdataadapter = new SqlDataAdapter(SQL, con);
            Consultantdataadapter.Fill(consultantTable);
//Fill the consultantTable with the SQL querry in memory....  Does that mean it actually populate the database?
0
Comment
Question by:yguyon28
3 Comments
 
LVL 16

Accepted Solution

by:
Wasim Akram Shaik earned 500 total points
ID: 40002055
I don't think so.. as you are not doing any activity at database end, apart from just logging in a user activity table..

you must be doing some other thing.. like loading of some other database table with configuration values in memory, so that object gets referred else where in the execution of the program further..
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 40002071
no and also you have no commande parameters adding any value to the table

for example

cmd.Parameters.Add("@username", System.Data.SqlDbType.NVarChar).Value = username.Text;


additionally your not executing the query
cmd.ExecuteNonQuery();
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40002267
I imagine the code you have will simply throw an exception if you tried to run it.

The DataTable Fill() method populates the DataTable from the database using a SELECT statement. An INSERT statement would suggest a push to the database, whereas the Fill() method is used to pull from the database.
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question