Click here to Skip to main content
15,885,182 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello guys am very new to webmatrix environment and am kind of having a challenge on
storing mulltiple data of texboxes into a single column but different roles..

i tried using the stringBuilder to append the records but i get this error.

No mapping exists from DbType System.Text.StringBuilder to a known SqlCeType.

here is my code below.i dont know wat am doing wrong..




C#
if(IsPost){
  department=Request["categoryId"];
  program=Request["program"];
  program1=Request["program1"];
  if(department.IsEmpty()){

      ModelState.AddError("categoryId","department is needed");

  }

  if(ModelState.IsValid){

  StringBuilder add =new StringBuilder();
  add.Append("program");
  add.Append("program1");


      var sql="insert into grade"+"(course_name)"+"values(@0)";
      db.Execute(sql,add);

  }


i will really appreciate your help and assistance
Posted

1 solution

Quote:
No mapping exists from DbType System.Text.StringBuilder to a known SqlCeType.

to fix that, try with ToString method
C#
var sql="insert into grade (course_name) values(@0)";
db.Execute(sql,add.ToString());
 
Share this answer
 
Comments
Uvie Chizzy Jakpor 13-Nov-14 2:14am    
thank you @Damithsl.it works perfectly..but its appends all the records in one column in d database.is there a way i can put each program on a diffrent row but the same column
DamithSL 13-Nov-14 2:23am    
var sql="insert into grade (course_name) values(@0)";
db.Execute(sql,program);
db.Execute(sql,program1);
Uvie Chizzy Jakpor 13-Nov-14 2:58am    
thanks so much,you really a good programme,but is there a way i can iterate over texboxes dan rather calling the execute everytime,because am having 8 textboxes of program,grade which means i call the db.execute 8 times

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900