| Forum: SQL | 
																Thema: 
																	AW: AW: MS SQL 2000 - COLUMN FOREIGN KEY-Einschränkung | 
																	Von: 
																		M Merlin (
																	18.04.2007 15:45) | 
														
													
												
            
		Dim NewRow As Integer
Dim strSql As String
Dim ConnObj As New SqlConnection(PstrConnString)
Dim MyTrans As SqlTransaction
    Try
      ConnObj.Open()
    Catch ex As SqlException
      ConnObj.Close()
      ConnObj.Dispose()
      errMsg = "SaveIt - Kein Datenbankzugriff möglich !"
      Return False
    End Try
MyTrans = ConnObj.BeginTransaction(IsolationLevel.ReadCommitted)
strSql = "INSERT INTO Tage (Datum) VALUES ('" & vbDBDate(Datum, True) & "')"
        NewRow = (New SqlCommand(strSql, ConnObj, MyTrans)).ExecuteNonQuery
        strSql = "SELECT @@IDENTITY"
        Dim cmd As New SqlCommand(strSql, ConnObj, MyTrans)
        DatumID = CLng(cmd.ExecuteScalar)
For inti As Integer = 0 To Rohstoffe.Count - 1
        strSql = "INSERT INTO Daten (IDTag,IDRohstoff,Gewicht) VALUES (" & CLng(DatumID) & "," & Rohstoffe.Item(inti).MaterialID & "," & Replace(Rohstoffe.Item(inti).Gewicht.ToString, Komma, Punkt) & ")"
        NewRow = (New SqlCommand(strSql, ConnObj, MyTrans)).ExecuteNonQuery
      Next
      MyTrans.Commit()
	
	
													
												
            
														
							Antworten
							
							
							Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!