Here is my code in my Class Named DBHandler!!!
Expand|Select|Wrap|Line Numbers
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data.SqlClient;
- using Program;
- using CustomTypes;
- using System.Data;
- using System.Configuration;
- namespace InformationDesk
- {
- public class DBHandler
- {
- public void GetAllValues(Person V)
- {
- SqlConnection con = new SqlConnection();
- con.ConnectionString = ConfigurationManager.ConnectionStrings["FinalProjectDB"].ConnectionString;
- SqlCommand com = new SqlCommand();
- com.CommandText = "INSERT INTO Visitors (Name, Email) VALUES (@Name, @Email);";
- com.Connection = con;
- com.Parameters.Add("@Name", SqlDbType.NVarChar, 50).Value = V.Name;
- com.Parameters.Add("@Email", SqlDbType.NVarChar, 50).Value = V.Email;
- con.Open();
- com.ExecuteNonQuery();
- con.Close();
- }
- }
- }
And i am using GetAllValues function to get values from user in a windows form
after getting values from user assign them to sql command parameters to insert but fcing an error please help me as soon as possible however i am sure that the function GetAllValues need some maintenance in the above code snippte...