1 Replies - 1179 Views - Last Post: 24 April 2011 - 06:42 AM

#1 En3myx0fxG0d  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 17-February 09

Sending ChannelUri to SQL databse

Posted 23 April 2011 - 11:44 AM

I'm writing an application that needs to update from a server (since this is just strictly for learning/personal project I'm using SQLEXPRESS inside visual studio). I'm trying to send information to the SQL server inside my WCF application. My problem right now is that I can't seem to get a ChannelUri string to send correctly to the database. The query works fine without it.

First
myCommand.CommandText = String.Format("INSERT INTO PhoneInformation (Guid, DateAdded, TimePutIn, uri) VALUES ('{0}','{1}','{2}', {3})", guid, dateAdded, timePutIn, uri);



Second
myCommand.CommandText = "INSERT INTO PhoneInformation (Guid, DateAdded, TimePutIn, uri) VALUES (@guid, @dateAdded,@timePutIn,@uri";
                myCommand.Parameters.Add("@guid", System.Data.SqlDbType.VarChar).Value = guid;
                myCommand.Parameters.Add("@dateAdded", System.Data.SqlDbType.DateTime).Value = dateAdded;
                myCommand.Parameters.Add("@timePutIn", System.Data.SqlDbType.Int).Value = timePutIn;
                myCommand.Parameters.Add("@uri", System.Data.SqlDbType.VarChar).Value = uri;



So far neither have worked and I get a "FaultException was unhandled" but once I remove the uri string from the query it works fine So I believe something in the string is not being escaped right and messing up the query. If anyone can give me any direction on simply getting the ChannelUri to insert you would definitely be helping me overcome a huge problem right now.

Is This A Good Question/Topic? 0
  • +

Replies To: Sending ChannelUri to SQL databse

#2 En3myx0fxG0d  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 17-February 09

Re: Sending ChannelUri to SQL databse

Posted 24 April 2011 - 06:42 AM

So don't know how. don't know why, didn't change anything but code is working now.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1