B
Butt Chin Chuan
I want to insert record into my SqlCe database. However, I
got an unknown error message. The breakpoint is pointed to
my consql.open statement. I followed the msdn example
about the datasource and noticed that it is different from
my usual connection string. This is my usual connection
string:
Dim cn As SqlCeConnection = New SqlCeConnection( _
"DataSource=\My Documents\mydatabase.sdf")
My connection string (after followed MSDN) is as follows:
Dim cn As String = "Data Source = mydatabase.sdf;"
Below is my code:
Dim sql As String
sql = ""
sql = "INSERT INTO tbAcademicQualification "
sql = sql + "(MemberID, Degree, Field, Year_, "
sql = sql + "InstitutionName, InstitutionPlace) "
sql = sql + "VALUES ('"
sql = sql + CStr(cMemberID) + "', '"
sql = sql + CStr(txtDegreeDetail.Text) + "', '"
sql = sql + CStr(txtFieldDetail.Text) + "', '"
sql = sql + CStr(txtYearDetail.Text) + "', '"
sql = sql + CStr(txtInstitutionNameDetail.Text) + "', '"
sql = sql + CStr(txtInstitutionPlaceDetail.Text) + "') "
Dim cn As String = "Data Source = mbkms.sdf;"
Dim conSql As New SqlCeConnection(cn)
Dim cmd As New SqlCeCommand
cmd.Connection = conSql
cmd.CommandText = sql
conSql.Open()
cmd.ExecuteNonQuery()
conSql.Close()
I have a few questions here:
1) What is the actual connection string here?
2) Where exactly is "Data Source = mydatabase.sdf;"
actually refers to (location)?
3) My battery charger is spoilt, therefore I'm using the
emulator at the moment.
3i) How can I determine where (in my desktop computer) the
sdf file in the emulator resides?
4) Is the unknown error generated (break) on the
conSql.open statement is due to the location of the sdf
file not correct? If so, how can I set it in the
connection string where it can point to the correct
location?
Any suggestions is greatly appreciated. Thank you.
got an unknown error message. The breakpoint is pointed to
my consql.open statement. I followed the msdn example
about the datasource and noticed that it is different from
my usual connection string. This is my usual connection
string:
Dim cn As SqlCeConnection = New SqlCeConnection( _
"DataSource=\My Documents\mydatabase.sdf")
My connection string (after followed MSDN) is as follows:
Dim cn As String = "Data Source = mydatabase.sdf;"
Below is my code:
Dim sql As String
sql = ""
sql = "INSERT INTO tbAcademicQualification "
sql = sql + "(MemberID, Degree, Field, Year_, "
sql = sql + "InstitutionName, InstitutionPlace) "
sql = sql + "VALUES ('"
sql = sql + CStr(cMemberID) + "', '"
sql = sql + CStr(txtDegreeDetail.Text) + "', '"
sql = sql + CStr(txtFieldDetail.Text) + "', '"
sql = sql + CStr(txtYearDetail.Text) + "', '"
sql = sql + CStr(txtInstitutionNameDetail.Text) + "', '"
sql = sql + CStr(txtInstitutionPlaceDetail.Text) + "') "
Dim cn As String = "Data Source = mbkms.sdf;"
Dim conSql As New SqlCeConnection(cn)
Dim cmd As New SqlCeCommand
cmd.Connection = conSql
cmd.CommandText = sql
conSql.Open()
cmd.ExecuteNonQuery()
conSql.Close()
I have a few questions here:
1) What is the actual connection string here?
2) Where exactly is "Data Source = mydatabase.sdf;"
actually refers to (location)?
3) My battery charger is spoilt, therefore I'm using the
emulator at the moment.
3i) How can I determine where (in my desktop computer) the
sdf file in the emulator resides?
4) Is the unknown error generated (break) on the
conSql.open statement is due to the location of the sdf
file not correct? If so, how can I set it in the
connection string where it can point to the correct
location?
Any suggestions is greatly appreciated. Thank you.