Click here to Skip to main content
15,890,579 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionLock web application by domain Pin
m-khansari17-Aug-09 0:02
m-khansari17-Aug-09 0:02 
AnswerRe: Lock web application by domain Pin
Abhishek Sur17-Aug-09 0:47
professionalAbhishek Sur17-Aug-09 0:47 
GeneralRe: Lock web application by domain Pin
m-khansari17-Aug-09 0:50
m-khansari17-Aug-09 0:50 
GeneralRe: Lock web application by domain Pin
Abhishek Sur17-Aug-09 0:54
professionalAbhishek Sur17-Aug-09 0:54 
QuestionMake the email mail as READ in gmail. Pin
astrovirgin16-Aug-09 23:31
astrovirgin16-Aug-09 23:31 
AnswerRe: Make the email mail as READ in gmail. Pin
padmanabhan N16-Aug-09 23:55
padmanabhan N16-Aug-09 23:55 
AnswerRe: Make the email mail as READ in gmail. Pin
Abhishek Sur17-Aug-09 0:11
professionalAbhishek Sur17-Aug-09 0:11 
Questioncheck datatype in SqlBulkCopy Pin
pranavcool16-Aug-09 23:28
pranavcool16-Aug-09 23:28 
Hi,
I am inserting data from excel sheet to sql server table.
The following is the code which is used to export data from excel ti sql server table.

private void insdata()
       {
           try
           {
               string filename = "~\\Documents\\" + ViewState["MissionCat"];
               string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(filename) + "; Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1;\"";

               // Create Connection to Excel Workbook
               using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
               {
                   connection.Open();

                   OleDbCommand command = new OleDbCommand("Select [Mission] ,[Civilian] ,[Military] ,[Police]" +
                    ",[Unknown] ,[Non-UN] ,[Total] FROM [Sheet1$]", connection);

                   string sqlConnectionString = ConfigurationManager.ConnectionStrings["conn"].ToString();

                   //truncate the table before inserting new data.
                   SqlConnection cnntrunc = new SqlConnection(sqlConnectionString);
                   SqlCommand truntbleBU = new SqlCommand();
                   truntbleBU.Connection = cnntrunc;
                   string trunsqlBU = null;
                   trunsqlBU = "TRUNCATE TABLE MissionCatReport";
                   truntbleBU.CommandText = trunsqlBU;
                   cnntrunc.Open();
                   truntbleBU.ExecuteNonQuery();
                   cnntrunc.Close();

                   // Create DbDataReader to Data Worksheet
                   using (DbDataReader dr = command.ExecuteReader())
                   {
                       // Bulk Copy to SQL Server
                       using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString))
                       {
                           bulkCopy.DestinationTableName = "MissionCatReport";
                           bulkCopy.WriteToServer(dr);
                       }
                   }
               }
           }
           catch (Exception ex)
           {
               throw ex;
           }
       }


There is numeric field in table such as total.
Now i am getting an error when a user tries to export data from excel to sql table if the total column in excel sheet contains string value instead of numeric value because the total column in sql table is numeric. I want to keep the total column in sql table numeric.
I am getting the follwoing error.

The given value of type String from the data source cannot be converted to type int of the specified target column.

so before inserting data in to sql table i want to make a check that whether the excel column contains the right data.
Is it possible to check that, and if yes can anyone tell me how to do that check.

Pranav Dave

AnswerRe: check datatype in SqlBulkCopy Pin
Abhishek Sur16-Aug-09 23:54
professionalAbhishek Sur16-Aug-09 23:54 
QuestionHow to store comments Pin
kavinnagarajan16-Aug-09 23:25
kavinnagarajan16-Aug-09 23:25 
AnswerRe: How to store comments Pin
Abhishek Sur16-Aug-09 23:52
professionalAbhishek Sur16-Aug-09 23:52 
GeneralHow to store comments Pin
kavinnagarajan16-Aug-09 23:56
kavinnagarajan16-Aug-09 23:56 
GeneralRe: How to store comments Pin
Abhishek Sur17-Aug-09 0:08
professionalAbhishek Sur17-Aug-09 0:08 
AnswerRe: How to store comments Pin
padmanabhan N16-Aug-09 23:53
padmanabhan N16-Aug-09 23:53 
QuestionSocila site creation Pin
NidhiKanu16-Aug-09 22:33
professionalNidhiKanu16-Aug-09 22:33 
AnswerRe: Socila site creation Pin
Abhishek Sur16-Aug-09 22:42
professionalAbhishek Sur16-Aug-09 22:42 
AnswerRe: Socila site creation Pin
N a v a n e e t h16-Aug-09 22:45
N a v a n e e t h16-Aug-09 22:45 
Questionsearch option Pin
kavinnagarajan16-Aug-09 22:21
kavinnagarajan16-Aug-09 22:21 
AnswerRe: search option Pin
Christian Graus16-Aug-09 22:27
protectorChristian Graus16-Aug-09 22:27 
Generalsearch option Pin
kavinnagarajan16-Aug-09 22:35
kavinnagarajan16-Aug-09 22:35 
GeneralRe: search option Pin
N a v a n e e t h16-Aug-09 22:46
N a v a n e e t h16-Aug-09 22:46 
Generalsearch option Pin
kavinnagarajan16-Aug-09 23:21
kavinnagarajan16-Aug-09 23:21 
GeneralRe: search option Pin
Christian Graus16-Aug-09 22:53
protectorChristian Graus16-Aug-09 22:53 
GeneralRe: search option Pin
Abhishek Sur16-Aug-09 23:14
professionalAbhishek Sur16-Aug-09 23:14 
Questiondebug website Pin
farokhian16-Aug-09 21:58
farokhian16-Aug-09 21:58 

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.