Click here to Skip to main content
15,905,782 members
Home / Discussions / C#
   

C#

 
Questionquestion about web part ? Pin
abdallahziad26-Apr-06 2:31
abdallahziad26-Apr-06 2:31 
AnswerRe: question about web part ? Pin
The Ladies' Man26-Apr-06 3:08
The Ladies' Man26-Apr-06 3:08 
AnswerRe: question about web part ? Pin
Josh Smith26-Apr-06 3:31
Josh Smith26-Apr-06 3:31 
QuestionVad menas med detta [DefaultValue(false)]? Pin
Tony_Joh26-Apr-06 1:48
Tony_Joh26-Apr-06 1:48 
AnswerRe: Vad menas med detta [DefaultValue(false)]? Pin
J4amieC26-Apr-06 2:27
J4amieC26-Apr-06 2:27 
AnswerRe: What does this mean [DefaultValue(false)]? Pin
Guffa26-Apr-06 4:38
Guffa26-Apr-06 4:38 
GeneralRe: What does this mean [DefaultValue(false)]? Pin
J4amieC26-Apr-06 4:56
J4amieC26-Apr-06 4:56 
GeneralRe: What does this mean [DefaultValue(false)]? Pin
Guffa26-Apr-06 23:19
Guffa26-Apr-06 23:19 
QuestionScrolling button Pin
K.A.L26-Apr-06 1:21
K.A.L26-Apr-06 1:21 
AnswerRe: Scrolling button Pin
J4amieC26-Apr-06 2:29
J4amieC26-Apr-06 2:29 
GeneralRe: Scrolling button Pin
K.A.L26-Apr-06 2:45
K.A.L26-Apr-06 2:45 
GeneralRe: Scrolling button Pin
sathish s26-Apr-06 4:05
sathish s26-Apr-06 4:05 
GeneralRe: Scrolling button Pin
J4amieC26-Apr-06 4:51
J4amieC26-Apr-06 4:51 
GeneralRe: Scrolling button Pin
K.A.L26-Apr-06 5:06
K.A.L26-Apr-06 5:06 
QuestionTrapping WinKey + D Key Combination Pin
Ecologic26-Apr-06 1:06
Ecologic26-Apr-06 1:06 
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 

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.