I have a problem filling up a table into my SQL Database. I can write in almost every table, accept from one of them.
I'll explain the situation. I have a table, I'll call it X, and another one, let's say Y. I can fill up both without any problem, so I guess my connection to the DB can't be very wrong. Now, there is a many-to-many connection between those tables, therefor I made an extra table, called XY. There is the problem, seems like I can't write into that one. I already tried to rename it, without result, I even deleted it and started all over, but still I can't write into that table. As a matter of fact, I can, when I'm in the query analyzer of SQL Server itself. But I can't when I'm trying to connect to it through ASP.NET.
Here's the code I'm using :
Can somebody help me please? I can't seem to find the mistake :s
I'll explain the situation. I have a table, I'll call it X, and another one, let's say Y. I can fill up both without any problem, so I guess my connection to the DB can't be very wrong. Now, there is a many-to-many connection between those tables, therefor I made an extra table, called XY. There is the problem, seems like I can't write into that one. I already tried to rename it, without result, I even deleted it and started all over, but still I can't write into that table. As a matter of fact, I can, when I'm in the query analyzer of SQL Server itself. But I can't when I'm trying to connect to it through ASP.NET.
Here's the code I'm using :
Code:
'set up connection
Dim myConnection As New SQLConnection()
myConnection.ConnectionString = "Data Source=[IP];" & _
"Initial Catalog=[Database];" & _
"User ID=***;" & _
"Password=***"
MyConnection.Open()
...
If btBier.Text = "Nieuw"
BierId = ddlBier.SelectedItem.Value
Else
Dim myCommandBier As New SQLCommand _
("insert into Bier VALUES('"& tbNaamBier.Text & "','" & BrouwerId & "') SELECT @@Identity", myConnection)
BierId = myCommandBier.ExecuteScalar()
End if
Dim myCommandKaart As New SQLCommand _
("insert into Kaart VALUES('"& tbTekst.Text & "','" & tbVorm.Text & "') SELECT @@Identity", myConnection)
KaartId = myCommandKaart.ExecuteScalar()
Dim myCommandKaartBier As New SQLCommand _
("insert into kaartbier VALUES('" & KaartId & "','" & BierId & "')", myConnection)
Can somebody help me please? I can't seem to find the mistake :s