我有这个技能复选框列表,其中包含用户可以选择的技能。如果用户选择两项技能,则会在表格中插入两条记录。 我试过这个:
Dim varSkillID As Integer()
varSkillID = split(skills, ",")
If varSkillID(0).value > 0 Then
Dim sql As String = Nothing
For I = 0 To varSkillID()
sql = "INSERT INTO tblConstituentSkills (skillID) VALUES ( " & varSkillID.Value & ")"
Next I
end if
但它不起作用。谢谢!
我也试过这段代码。
Dim varSkillID() As String = Split(skillID, ",")
For i As Integer = 0 To varSkillID.Length - 1
If varSkillID(i) <> "" Then
Using sql As New SqlProcedure("spInsertSkill")
sql.AddParameter("@ConstituentIdNo", constituentIdNo)
sql.AddParameter("@skillID", varSkillID(i))
sql.ExecuteNonQuery()
End Using
End If
Next i
当我只选择单一技能时,它有效。但是,如果我选择了两个或更多技能,则会出现“Nullable对象必须具有值”的错误。
答案 0 :(得分:1)
public Uri addScheduleToCalender(String title,String place,String description) {
long calID = 3;
long startMillis = 0;
long endMillis = 0;
Calendar beginTime = Calendar.getInstance();
beginTime.set(2016, 07, 22, 17, 30);
startMillis = beginTime.getTimeInMillis();
Calendar endTime = Calendar.getInstance();
endTime.set(2016, 07, 22, 18, 45);
endMillis = endTime.getTimeInMillis();
ContentValues values = new ContentValues();
ContentResolver cr = getContentResolver();
values.put(CalendarContract.Events.EVENT_LOCATION, place);
values.put(CalendarContract.Events.DTSTART, startMillis);
values.put(CalendarContract.Events.DTEND, endMillis);
values.put(CalendarContract.Events.TITLE, title);
values.put(CalendarContract.Events.DESCRIPTION, description);
values.put(CalendarContract.Events.CALENDAR_ID, calID);
values.put(CalendarContract.Events.EVENT_TIMEZONE, "UTC/GMT +2:00");
Uri uri;
if (Build.VERSION.SDK_INT >= 8) {
uri = Uri.parse("content://com.android.calendar/events");
} else {
uri = Uri.parse("content://calendar/events");
}
Uri l_uri = cr.insert(CalendarContract.Events.CONTENT_URI, values);
return l_uri;
}
End If
来自哪里?致电Sub:
constituentIdNo.Value
Sub:
Call r101("123456", "1,2,3,4")
这不是最干净的代码,但是我可以根据您给出的反馈创建最好的代码。 我不明白为什么要将技能转换为整数。
答案 1 :(得分:0)
我刚读完这封信并救了我。separate comma separated values and store in table in sql server 谢谢stackoverflow!你是一个救世主!