Click here to Skip to main content
16,013,648 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem with Listview,help! Pin
imbiz5-Jun-10 16:21
imbiz5-Jun-10 16:21 
QuestionUsing connection continuously Pin
teknolog1235-Jun-10 6:36
teknolog1235-Jun-10 6:36 
AnswerRe: Using connection continuously Pin
Not Active5-Jun-10 7:02
mentorNot Active5-Jun-10 7:02 
GeneralRe: Using connection continuously Pin
teknolog1235-Jun-10 8:30
teknolog1235-Jun-10 8:30 
GeneralRe: Using connection continuously Pin
Luc Pattyn5-Jun-10 8:50
sitebuilderLuc Pattyn5-Jun-10 8:50 
AnswerRe: Using connection continuously Pin
Luc Pattyn5-Jun-10 7:19
sitebuilderLuc Pattyn5-Jun-10 7:19 
AnswerRe: Using connection continuously Pin
Erik Funkenbusch6-Jun-10 11:01
Erik Funkenbusch6-Jun-10 11:01 
QuestionComplex SQL Insert Query Pin
TenRC5-Jun-10 5:05
TenRC5-Jun-10 5:05 
Hey guys, I am stumped with this one.

Here is an Insert Statement that works fine in my SQLEXPRESS database.

da.InsertCommand = new SqlCommand("INSERT INTO VW411Data VALUES('S100000','P100000','12/08/57','11:04','Steven Baldwin', 'C:\\ImageDir\\S100000a.jpg', 'C:\\ImageDir\\S100000b.jpg', '0','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1')", cs);

The first seven fields come from objects on my form and I wrote a simple query using command parameters to create a partial record. This works also.

da.InsertCommand = new SqlCommand("INSERT INTO VW411Data(SerialNbr, ModelID, Date, Time, UserName, ImageLink1, ImageLink2, Pass,) VALUES(@SerialNbr, @ModelID, @Date, @Time, @UserName, @ImageLink1, @ImageLink2, @Pass)", cs);
da.InsertCommand.Parameters.Add("@SerialNbr", SqlDbType.Char).Value = tbBC1.Text;
da.InsertCommand.Parameters.Add("@ModelID", SqlDbType.Char).Value = tbBC2.Text;
da.InsertCommand.Parameters.Add("@Date", SqlDbType.Char).Value = textBox3.Text;
da.InsertCommand.Parameters.Add("@Time", SqlDbType.Char).Value = textBox4.Text;
da.InsertCommand.Parameters.Add("@UserName", SqlDbType.VarChar).Value = tbUserName.Text;
da.InsertCommand.Parameters.Add("@ImageLink1", SqlDbType.VarChar).Value = "C:\\ImageDir\\" + tbBC1.Text +"a.jpg";
da.InsertCommand.Parameters.Add("@ImageLink2", SqlDbType.VarChar).Value = "C:\\ImageDir\\" + tbBC1.Text + "b.jpg";
da.InsertCommand.Parameters.Add("@Pass", SqlDbType.Int).Value = 1;

cs.Open();
da.InsertCommand.ExecuteNonQuery();
cs.Close();

The remaining fields are coming from a vision system over Ethernet in a csv format. My plan was to build a statement using a variable to hold the string for the remaining fields and attach the variable to a SQL statement. My final SQL Insert statement will be an all statement so I won't have to identify the fields. Here is my question...

Can I build a statement that contains both the command parameters and holds a variable containing the remaining statement or must I create two Insert statements (First 8 fields, then remaining 126 fields)? I know the latter is preferred but it will require me to identify all of the fields in my query for a partial Insert.

I do not get involved with SQL very often so my status is newbie at this point.

Thanks of all suggestions.

Steve
AnswerRe: Complex SQL Insert Query Pin
Not Active5-Jun-10 6:58
mentorNot Active5-Jun-10 6:58 
GeneralRe: Complex SQL Insert Query Pin
TenRC5-Jun-10 13:23
TenRC5-Jun-10 13:23 
QuestionEF question -- get a name of a table [modified] Pin
Lutosław5-Jun-10 4:49
Lutosław5-Jun-10 4:49 
AnswerRe: EF question -- get a name of a table Pin
Not Active5-Jun-10 6:51
mentorNot Active5-Jun-10 6:51 
GeneralRe: EF question -- get a name of a table Pin
Lutosław5-Jun-10 12:14
Lutosław5-Jun-10 12:14 
GeneralRe: EF question -- get a name of a table Pin
Not Active5-Jun-10 13:03
mentorNot Active5-Jun-10 13:03 
GeneralRe: EF question -- get a name of a table Pin
Lutosław5-Jun-10 13:50
Lutosław5-Jun-10 13:50 
GeneralRe: EF question -- get a name of a table Pin
Not Active5-Jun-10 15:18
mentorNot Active5-Jun-10 15:18 
GeneralRe: EF question -- get a name of a table Pin
Lutosław6-Jun-10 4:04
Lutosław6-Jun-10 4:04 
Questionhow to handle Server Not found exception at client side in .net remoting? Pin
amit_834-Jun-10 22:48
professionalamit_834-Jun-10 22:48 
AnswerRe: how to handle Server Not found exception at client side in .net remoting? Pin
#realJSOP5-Jun-10 2:02
professional#realJSOP5-Jun-10 2:02 
Questionoutput confusion Pin
Unknown Ajanabi4-Jun-10 22:03
Unknown Ajanabi4-Jun-10 22:03 
AnswerRe: output confusion Pin
Estys4-Jun-10 22:18
Estys4-Jun-10 22:18 
AnswerRe: output confusion [modified] Pin
DaveyM695-Jun-10 1:35
professionalDaveyM695-Jun-10 1:35 
AnswerRe: output confusion Pin
#realJSOP5-Jun-10 1:58
professional#realJSOP5-Jun-10 1:58 
GeneralRe: output confusion Pin
DaveyM695-Jun-10 2:20
professionalDaveyM695-Jun-10 2:20 
GeneralRe: output confusion Pin
Luc Pattyn5-Jun-10 2:47
sitebuilderLuc Pattyn5-Jun-10 2:47 

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.