C# - How to save the values of listview into a single row of table


hello guys!

i developing students profiling system. in program have listview grades of student saved semesters.

my problem is, how save values of listview in single row table?

in other websites, should use loop statement , arrays, don't know how that.

please help.

ok, assume data 1 student? , have student table in database? (you should). student table should have primary key (pk). need in tbl_tertiary database table column contains studentkey (this called foreign key, or fk). , have parent-child relationship (with student parent, , data in tbl_tertiary child). if don't have that, need add it.

so then, when insert each row listview separate row in tbl_tertiary database table (which result in 2 rows in table, in case of data in screenshot), you'd have include studentkey, "links" both of these rows student.

for (i = 0; <= terlistview.items.count - 1; i++) {     sqlcommand intertiary = con.createcommand();     intertiary.commandtext = "insert dbo.tbl_tertiary(studentkey, terschool, terstudenttype, terstudentstatus, tercourse, teryear, tersection, tergrade, terremarks) values(@terschool, @terstudenttype, @terstudentstatus, @tercourse, @teryear, @tersection, @tergrade, @terremarks)";     intertiary.parameters.addwithvalue("@studentkey", thestudentkey);     intertiary.parameters.addwithvalue("@terschool", terlistview.items[i].text);          // rest of code } 


~~bonnie dewitt [c# mvp]

http://geek-goddess-bonnie.blogspot.com



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'