Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DataTable Fill

Posted on 2014-04-15
3
Medium Priority
?
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Accepted Solution

by:
Wasim Akram Shaik earned 1500 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 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