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

C#

 
QuestionProblem Read Data From COM Port ... Pin
SD326-Apr-06 0:38
SD326-Apr-06 0:38 
Questionhow to move the button controls inside panel Pin
Supriya Walvekar25-Apr-06 23:39
Supriya Walvekar25-Apr-06 23:39 
AnswerRe: how to move the button controls inside panel Pin
alexey N26-Apr-06 0:25
alexey N26-Apr-06 0:25 
QuestionDisplaying Message Pin
pavanabollineni25-Apr-06 22:53
pavanabollineni25-Apr-06 22:53 
AnswerRe: Displaying Message Pin
krishna nimmalapudi26-Apr-06 3:32
krishna nimmalapudi26-Apr-06 3:32 
GeneralRe: Displaying Message Pin
pavanabollineni26-Apr-06 18:27
pavanabollineni26-Apr-06 18:27 
AnswerRe: Displaying Message Pin
Josh Smith26-Apr-06 3:34
Josh Smith26-Apr-06 3:34 
Questionproblems with INSERT to database Pin
valiovalio25-Apr-06 21:49
valiovalio25-Apr-06 21:49 
Hi, I want to insert into my database some information, I have everything in file a.txt:

INSERT INTO TLK (kodas, liga) VALUES ('(01-99)', 'Traumu priežastys (ne iš TLK10 klasifikacijos)')
INSERT INTO TLK (kodas, liga) VALUES ('01-99', 'Ne TLK10 traumu priežasciu klasifikacija')
INSERT INTO TLK (kodas, liga) VALUES ('1', 'Transporto ivykis')

a.txt contains about 10 000 records. I run this program, but everytime it breaks, it shows error that data would be truncated... how can I fix that?



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Kikilis
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string eilute;
int id = 0;
StringBuilder errorMessages = new StringBuilder();

private void button1_Click(object sender, EventArgs e)
{
try
{
System.IO.StreamReader sr = new System.IO.StreamReader("a.txt");
eilute = sr.ReadLine();
string j = "Data Source=KOMPAS;Initial Catalog=MEDIS;Integrated Security=True";
SqlConnection c = new SqlConnection(j);
c.Open();

while (eilute != "" || eilute == null)
{

SqlCommand cmd = new SqlCommand(eilute, c);

cmd.ExecuteNonQuery();
cmd.Dispose();
eilute = sr.ReadLine();

}
c.Close();
}
catch (SqlException ex)
{
for (int i = 0; i < ex.Errors.Count; i++)
{
errorMessages.Append("Index #" + i + "\n" +
"Message: " + ex.Errors[i].Message + "\n" +
"LineNumber: " + ex.Errors[i].LineNumber + "\n" +
"Source: " + ex.Errors[i].Source + "\n" +
"Procedure: " + ex.Errors[i].Procedure + "\n");
}
Console.WriteLine(errorMessages.ToString());
}

}
}
}
AnswerRe: problems with INSERT to database Pin
Guffa25-Apr-06 22:30
Guffa25-Apr-06 22:30 
GeneralRe: problems with INSERT to database Pin
valiovalio25-Apr-06 22:53
valiovalio25-Apr-06 22:53 
AnswerRe: problems with INSERT to database Pin
Rob Philpott25-Apr-06 22:34
Rob Philpott25-Apr-06 22:34 
QuestionNUnit Console Pin
Vasudevan Deepak Kumar25-Apr-06 21:26
Vasudevan Deepak Kumar25-Apr-06 21:26 
AnswerRe: NUnit Console Pin
Rob Philpott25-Apr-06 22:42
Rob Philpott25-Apr-06 22:42 
GeneralRe: NUnit Console Pin
Vasudevan Deepak Kumar26-Apr-06 6:00
Vasudevan Deepak Kumar26-Apr-06 6:00 
QuestionRemoving checkbox from datagridview column on certain rows. Pin
tomasaberg25-Apr-06 21:06
tomasaberg25-Apr-06 21:06 
AnswerRe: Removing checkbox from datagridview column on certain rows. Pin
AmitSumit26-Apr-06 0:30
AmitSumit26-Apr-06 0:30 
GeneralRe: Removing checkbox from datagridview column on certain rows. Pin
tomasaberg26-Apr-06 4:26
tomasaberg26-Apr-06 4:26 
QuestionPossible to databind a Winforms DataGrid to a DataReader? Pin
Jakob Farian Krarup25-Apr-06 21:03
Jakob Farian Krarup25-Apr-06 21:03 
QuestionDrawing, Drag Drop Problem in custom control Pin
crazymubashir25-Apr-06 20:56
crazymubashir25-Apr-06 20:56 
Questionhow to deploy a project with framework Pin
dayakar_dn25-Apr-06 20:29
dayakar_dn25-Apr-06 20:29 
AnswerRe: how to deploy a project with framework Pin
abhinish25-Apr-06 21:04
abhinish25-Apr-06 21:04 
GeneralRe: how to deploy a project with framework Pin
dayakar_dn25-Apr-06 22:08
dayakar_dn25-Apr-06 22:08 
QuestionShutdown PC Pin
phucoi25-Apr-06 19:58
phucoi25-Apr-06 19:58 
AnswerRe: Shutdown PC Pin
CWIZO25-Apr-06 21:38
CWIZO25-Apr-06 21:38 
AnswerRe: Shutdown PC Pin
Mohammad Dayyan11-Sep-09 9:29
Mohammad Dayyan11-Sep-09 9:29 

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.