|
thanks.i will talk with hosting company according to your advice.
|
|
|
|
|
snehasish wrote: thanks
No problem
If for some reason it becomes a problem to get access from host to the client, you always have other options. For example:
- you could create a stored procedure which takes the xml-data as a parameter. After that you load the data into the xmlproperty-table inside the procedure (not necessarily using file in this case).
- you could use ftp or something else to upload the file to the database server (or near it) and after that you use openrowset from the ftp target location
- if you're using .Net framework at client side, you could use SqlBulkCopy class at the client to load the data to the table etc.
|
|
|
|
|
hi,
Many thanks for giving possible soln. i have tried this one:
........
ds.readxml("http://www.myweb.com/xyz.xml")
Dim xmldoc As New XmlDataDocument(ds)
Dim xd As String = xmldoc.OuterXml()
Dim con As New SqlConnection(constr)
Dim sqlstr As String = "insert into xmlproperty values( convert (xml," & xd & " ))"
Dim com As New SqlCommand(sqlstr, con)
con.Open()
Dim i As Integer = com.ExecuteNonQuery()
con.Close()
.........
first i fill dataset by readxml() method.Then i take xml in variable xd.then i am trying to insert this xml to xmlproperty table.But i get an error:
Incorrect syntax near '<'. The label 'http' has already been declared. Label names must be unique within a query batch or stored procedure. asp.net
how to fix this error.
Thanks.
|
|
|
|
|
hi,
i still getting sql error for this code:
........
ds.readxml("http://www.myweb.com/xyz.xml")
Dim xmldoc As New XmlDataDocument(ds)
Dim xd As String = xmldoc.OuterXml()
Dim con As New SqlConnection(constr)
Dim sqlstr As String = "insert into xmlproperty values( convert (xml," & xd & " ))"
Dim com As New SqlCommand(sqlstr, con)
con.Open()
Dim i As Integer = com.ExecuteNonQuery()
con.Close()
.........
Error:Incorrect syntax near '<'. The label 'http' has already been declared. Label names must be unique within a query batch or stored procedure.
Any help me..
Thanks
Snehasish
|
|
|
|
|
snehasish wrote: Dim sqlstr As String = "insert into xmlproperty values( convert (xml," & xd & " ))"
snehasish wrote: Incorrect syntax near '<'. The label 'http' has already been declared
Don't concatenate the xml to the SQL statement. Instead use parameters (see: SqlParameter[^]).
|
|
|
|
|
Hi;
For some reason i had to go to out of station.According to your suggestion i have solved this.I think you are great.All of your given possible soln is very good.Thank you again.Thanks a lot.
this is my code in vb.net:
Dim ds As New DataSet
ds.ReadXml("http://www.myweb.com/abc.xml")
Dim doc As New XmlDataDocument(ds)
Dim con As New SqlConnection("Server=x.x.x.x;Database=celtic;User ID=xxxx;Password=xxxx;Trusted_Connection=False")
Dim com As New SqlCommand("sp_InsertXmlData", con)
com.CommandType = CommandType.StoredProcedure
com.Parameters.Add("@XMLDOC", SqlDbType.Text).Value = doc.OuterXml
con.Open()
Dim i As Integer = com.ExecuteNonQuery()
con.Close()
This is stored procedure:
Create PROCEDURE [dbo].[sp_InsertXmlData]
@XMLDOC text
AS
BEGIN
insert into xml_properties(xmldoc)
values(@XMLDOC)
END
snehasish
|
|
|
|
|
Thanks for your kind words
|
|
|
|
|
I am using following command:
exec master..xp_cmdshell 'bcp "select * from cab.useraudit" queryout "c:\test.xls" -c -T'
On execution I am getting following error:
Error = [Microsoft][SQL Native Client]An error has occurred while establishing a connection to
the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the
default settings SQL Server does not allow remote connections
I have configured the server to allow remote connections. What might be wrong?
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
|
Yes I am. I doubted myself and reconfigured everything. Still no help. I am running this on Vista. Is that the problem?
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
I have not tried on Vista. Well did you tried with -U (Userid) and -P (password) switches for bcp command ?
Parwej Ahamad
|
|
|
|
|
It may be firewall issue.
Parwej Ahamad
|
|
|
|
|
If your instance isn't the default instance, you must specify it. Try adding to the end:
-S.\instancename
|
|
|
|
|
I have just the one instance running. Now my belief is getting stronger. Its vista thats playing evil.
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
d@nish wrote: Its vista thats playing evil
I'm not so sure about it. I've got Vista and just tested your problem. Nothing wrong...
Even though you only have one instance it's not necessarily configured as the default. It still may be a named instance. Give it a try. At least if not working it eliminates one possibility.
|
|
|
|
|
Thanks Mika. I have sort of progressed. Now this is what I have done:
exec master..xp_cmdshell 'bcp "select * from cab.useraudit" queryout "c:\test.xls" -S "MACHINE\SQLEXPRESS" -U "uid" -P "pwd"'
Now I am getting this error:
Error = [Microsoft][SQL Native Client][SQL Server]Login failed for user 'Machine\Danish'.
The user is not associated with a trusted SQL Server connection.
How to deal with this?
Please bear. This is the first time I am writing a decent stored procedure.
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
Try also with -T and -P switches.
Parwej Ahamad
|
|
|
|
|
Its not a trusted connection. And with a trusted connection, why would I give a password?
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
Instead of using -U and -P switches, use the -T switch (integrated security). In that case yuo connect to the database with the same credentials which actually run the database.
d@nish wrote: Please bear. This is the first time I am writing a decent stored procedure
No problem at all
|
|
|
|
|
Thats where the problem is. SQL doesnt trusts the connection I am using. How can I win its trust?
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
Did you try -T after using the instance name with -S?
Also with -S and -T switches, what kind of error message you get. The test call I used for this is:
exec master..xp_cmdshell 'bcp "SELECT GETDATE()" queryout "e:\result.txt" -S ".\SOMEINSTANCENAME" -c -T'
Note that I'm using dot instead of server name. This may affect the protocol used.
|
|
|
|
|
I have got things working now. The problen is that the data gets corrupted when saved to file. I have tried '-N' but doesnt helps.
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
d@nish wrote: I have got things working now
Good
d@nish wrote: The problen is that the data gets corrupted when saved to file. I have tried '-N' but doesnt helps
have you tried -w
|
|
|
|
|
Great job Mika. I really appreciate your patience and skills. Thanks a lot. you made it possible for me. Next task is to send mail and this time I will do it on my own.
Some more praise for you right here.[^]
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
|
|
|
|
|
d@nish wrote: Thanks a lot
You're welcome
d@nish wrote: Next task is to send mail and this time I will do it on my own
I'm sure it will be good!
|
|
|
|