StrataFrame Forum

ConnectionString error

http://forum.strataframe.net/Topic23766.aspx

By Marcel Heitlager - 7/7/2009

Hi guys,



When I call the function below, I get a "Format of the initialization string does not conform to specification starting at index 0." error at the line where I set the connection string. I'm trying to clear the SQL Server Tables on the server through ES. Since it works on a local database, what do I need to change so it will play nice with ES? Thanks.





Public Function ClearPPMTables(ByVal dbName As String) As Boolean



Using conn As New SqlConnection



conn.ConnectionString = MicroFour.StrataFrame.Data.DataLayer.DataSources(me.DataSourceKey).ConnectionString

conn.Open()



Using cmd As New SqlCommand

cmd.CommandType = CommandType.StoredProcedure

cmd.CommandText = "dbo.sp_ClearTables"

cmd.Parameters.Add("@dbname", SqlDbType.NVarChar, 128)

cmd.Parameters("@dbname").Value = dbName.Trim

cmd.Connection = conn

Me.ExecuteNonQuery(cmd)



End Using

End Using

End Function
By Trent L. Taylor - 7/8/2009

Well, remember that the ES is actually where the connection string is..so you need to pass this logic over in the form of a query versus trying to create the connection local. All query traffic is passed over to the ES and then executed server side. So in this case, I am not sure why you are trying to set the connection yourself anyway. From the looks of the code, it appears that this is within a BO anyway. So there is no need to set the connection, just execute the query.



Public Function ClearPPMTables(ByVal dbName As String) As Boolean



Using cmd As New SqlCommand

cmd.CommandType = CommandType.StoredProcedure

cmd.CommandText = "dbo.sp_ClearTables"

cmd.Parameters.Add("@dbname", SqlDbType.NVarChar, 128)

cmd.Parameters("@dbname").Value = dbName.Trim

Me.ExecuteNonQuery(cmd)



End Using

End Function
By Marcel Heitlager - 7/8/2009

The reason why I didn't do it that way is because it makes too much sense. Especially since I allready did it the correct way in the function right below it. Blush



I figured, however, that this would allow you to add another one to your, "They shouldn't be allowed to use our framework, if:" list. BigGrin



As always, thanks again.



Public Function BackupDatabase(ByVal dbname As String) As Boolean



Using cmd As New SqlCommand()



cmd.CommandType = CommandType.StoredProcedure

cmd.CommandText = "dbo.BackupDatabase"

cmd.Parameters.Add("@dbname", SqlDbType.NVarChar, 128)

cmd.Parameters("@dbname").Value = dbname.Trim



Me.ExecuteNonQuery(cmd)



End Using

End Function
By Trent L. Taylor - 7/8/2009

I figured, however, that this would allow you to add another one to your, "They shouldn't be allowed to use our framework, if:" list. [BigGrin]




LOL...the thought NEVER crossed my mind...we have all been there! When you get in the heat of the battle sometimes you just resort to "getting the job done" and so I totally understand!