Click here to Skip to main content
15,890,186 members
Home / Discussions / Database
   

Database

 
QuestionDAO Notification? Pin
lynchspawn5-Jan-06 9:51
lynchspawn5-Jan-06 9:51 
AnswerRe: DAO Notification? Pin
Dave Kreskowiak6-Jan-06 5:05
mveDave Kreskowiak6-Jan-06 5:05 
QuestionPartial name Pin
gharry5-Jan-06 9:47
gharry5-Jan-06 9:47 
AnswerRe: Partial name Pin
Colin Angus Mackay5-Jan-06 11:01
Colin Angus Mackay5-Jan-06 11:01 
GeneralRe: Partial name Pin
gharry5-Jan-06 22:46
gharry5-Jan-06 22:46 
GeneralRe: Partial name Pin
Colin Angus Mackay6-Jan-06 1:45
Colin Angus Mackay6-Jan-06 1:45 
QuestionReading CSV file into DataGrid Pin
gharry5-Jan-06 5:32
gharry5-Jan-06 5:32 
QuestionProblem populating table Pin
TheJudeDude5-Jan-06 5:06
TheJudeDude5-Jan-06 5:06 
I am trying to write a program which parses a text file, stores certain values, then inserts these values into a table. The table has one primary auto key, with 8 columns. The data is getting put into the table ( somewhat ). Several columns that hold (char) values are only insert the first character into the column. I ran the program through the debugger, and the parameter items of the data adapter hold the correct values. Here is the method that handles the parse and insert command:
private void btnStart_Click(object sender, System.EventArgs e)
{
string strFilename;
int intStoreNumber;
StreamReader objRead;
string strRecord;
int intStore;
string strNU;
string strManf;
string strModel;
string strSerial;
decimal decCost;
decimal decNet;
DateTime dtDate;
int intCount = 0;

for (intStoreNumber = 1; intStoreNumber <= 20; intStoreNumber++)
{
if (intStoreNumber < 10)
{
strFilename = intStoreNumber.ToString();
strFilename = strFilename.Insert(0,"0");
}
else
{
strFilename = intStoreNumber.ToString();
}
strFilename = "invd" + strFilename + ".prn";
objRead = new StreamReader(strFilename);

while (objRead.Peek() > -1)
{
strRecord = objRead.ReadLine();
intCount++;
if (strRecord != "" && strRecord != "\\f" )
{
if (strRecord.Substring(14,1) == "N" | strRecord.Substring(14,1) == "U")
{
if(strRecord.Substring(14,3) != "NU-")
{
intStore = intStoreNumber;
strNU = strRecord.Substring(14,1);
strManf = strRecord.Substring(26,8);
strModel = strRecord.Substring(36,10);
strSerial = strRecord.Substring(47,12);
decCost = Decimal.Parse(strRecord.Substring(60,8));
decNet = Decimal.Parse(strRecord.Substring(70,8));
dtDate = DateTime.Parse(strRecord.Substring(79,10));



SqlCommand cmdNew = new SqlCommand("ProcessInventory", this.sqlConnInv);
SqlDataAdapter sdaNew = new SqlDataAdapter(cmdNew);
DataSet dsInventory = new DataSet();
cmdNew.Parameters.Add("@Store_ID", SqlDbType.Int).Value = intStore;

cmdNew.Parameters.Add("@NU", SqlDbType.Char).Value = strNU;

cmdNew.Parameters.Add("@MANUF", SqlDbType.Char).Value = strManf;

cmdNew.Parameters.Add("@MODELNO", SqlDbType.Char).Value = strModel;

cmdNew.Parameters.Add("@SERIALNO", SqlDbType.Char).Value = strSerial;

cmdNew.Parameters.Add("@ORIGCOST", SqlDbType.SmallMoney).Value = decCost;

cmdNew.Parameters.Add("@NETVAL", SqlDbType.SmallMoney).Value = decNet;

cmdNew.Parameters.Add("@DATEAQ", SqlDbType.SmallDateTime).Value = dtDate;

sdaNew.Fill(dsInventory1,"Inventory");
}
}
}
}

}

}


and here is the stored procedure:
ALTER PROCEDURE dbo.ProcessInventory
/*
(
@parameter1 datatype = default value,
@parameter2 datatype OUTPUT
)
*/
@Store_ID int,
@NU char,
@MANUF char,
@MODELNO char,
@SERIALNO char,
@ORIGCOST smallmoney,
@NETVAL smallmoney,
@DATEAQ smalldatetime
AS
/* SET NOCOUNT ON */
INSERT Inventory(Store_ID, NewUsed,Manf,Model,Serial,Cost,Net,DateAcc)
VALUES (@Store_ID, @NU, @MANUF, @MODELNO, @SERIALNO, @ORIGCOST, @NETVAL, @DATEAQ)

RETURN

The Manf,Model, and Serial columns are the ones not being updated correctly.

Here is the definition for the table:
Inv_Reco(P-Key) int 4
Store_ID int 4
NewUsed char 1 (allow nulls)
Manf char 20 (allow nulls)
Model char 20 (allow nulls)
Serial char 20 (allow nulls)
Cost smallmoney 4 (allow nulls)
Net smallmoney 4 (allow nulls)
DateAcc smaldatetime 4 (allow nulls)

I wrote another board and was told to use the Command.ExecuteNonQuery, but that did not work.
I am new to SQL databases w/ C#, so any input would be greatly appreciated
AnswerRe: Problem populating table Pin
Colin Angus Mackay5-Jan-06 6:45
Colin Angus Mackay5-Jan-06 6:45 
GeneralRe: Problem populating table Pin
TheJudeDude5-Jan-06 14:38
TheJudeDude5-Jan-06 14:38 
GeneralRe: Problem populating table Pin
Colin Angus Mackay5-Jan-06 20:45
Colin Angus Mackay5-Jan-06 20:45 
GeneralRe: Problem populating table Pin
TheJudeDude7-Jan-06 3:30
TheJudeDude7-Jan-06 3:30 
GeneralRe: Problem populating table Pin
Colin Angus Mackay7-Jan-06 3:42
Colin Angus Mackay7-Jan-06 3:42 
QuestionSQL query Pin
Deian5-Jan-06 4:33
Deian5-Jan-06 4:33 
AnswerRe: SQL query Pin
Colin Angus Mackay5-Jan-06 6:39
Colin Angus Mackay5-Jan-06 6:39 
GeneralRe: SQL query Pin
Deian5-Jan-06 7:32
Deian5-Jan-06 7:32 
QuestionRe: SQL query Pin
Deian6-Jan-06 5:22
Deian6-Jan-06 5:22 
QuestionJoin On Null?? Pin
tadhg885-Jan-06 3:05
tadhg885-Jan-06 3:05 
AnswerRe: Join On Null?? Pin
Colin Angus Mackay5-Jan-06 3:28
Colin Angus Mackay5-Jan-06 3:28 
GeneralRe: Join On Null?? Pin
tadhg885-Jan-06 4:42
tadhg885-Jan-06 4:42 
QuestionMSDE 2000 upgrade to SQL Server 2005 Developer Pin
Kevin McFarlane5-Jan-06 2:34
Kevin McFarlane5-Jan-06 2:34 
QuestionProblem with connection pooling Pin
nguyenvhn4-Jan-06 15:51
nguyenvhn4-Jan-06 15:51 
AnswerRe: Problem with connection pooling Pin
S. Akif Kamal4-Jan-06 18:21
S. Akif Kamal4-Jan-06 18:21 
GeneralRe: Problem with connection pooling Pin
nguyenvhn5-Jan-06 16:09
nguyenvhn5-Jan-06 16:09 
Questionkindly help me vb codes.. Pin
Estong Odpaga4-Jan-06 13:11
Estong Odpaga4-Jan-06 13:11 

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.