SQLQUERY

Mar 7, 2008

Hi,

Here is my SQL Query.

SQL = "insert into mnetwork..tblContactCorr(CorrespondentID,Name,Phone,Fax,Email,UserName,rowguid,Status,ChgPassword,lastlogin,MailNotification,USerLevel,LocationID,msrepl_tran_version)"
SQL = SQL & " values( '" & drpCorr.SelectedValue & "', '" & txtName.Text & "', '" & txtphone.Text & "', '" & txtFax.Text & "', '" & txtEmail.Text & "', '" & txtUserName.Text & "', '" & mGuid & "', '" & drpstatus.SelectedValue & "', '" & "Null" & "', '" & getdate & "', '" & drpmn.SelectedValue & " ', '" & drpuserlevel.SelectedValue & "', '" & drplocation.SelectedValue & "', '" & "Null" & "')"
Dim dbcommand As New SqlCommand(SQL, ObjConn)
ObjConn.Open()
dbcommand.ExecuteNonQuery()------>here is the problem

dbcommand = New SqlCommand("select @@identity", ObjConn)
Dim NewUserID = dbcommand.ExecuteScalar



After executing i am getting error like this:Message "Syntax error converting from a character string to uniqueidentifier." String

I don't know how to convert mguid into uniqueidentifier.

here is my batabase fields:

ContactID-->this is auto increment
CorrespondentID--int
Name-varchar
Phone-varchar
Fax-varchar
EMail-varchar
UserName-varchar
rowguid--uniqueiduntifier
status-tiniint
chgpassword-snallint
lastlogin--datetime
mailnotification--smallint
locationid--int
msrepl_tran_version-uniqueiduntifier -(this is null)

let me know whats wrong in this?

View 8 Replies


ADVERTISEMENT

Filling A DataTable From SqlQuery : If SqlQuery Returns Null Values Problem Ocurrs With DataTable

Sep 3, 2007

Filling a DataTable from SqlQuery : If SqlQuery returns some null values problem ocurrs with DataTable.
Is it possible using DataTable with some null values in it?
Thanks

View 2 Replies View Related

Parametres - SqlQuery

Jun 22, 2007

Could you pls let me know that when we use the parameters how the sql server ıs able to keep all the datas on the strıng type?and also how ıt can be provıde that securıty on system(how ıt ıgnore to do sql ınjectıon...).

View 1 Replies View Related

Get Excel File When Run Sqlquery

Dec 23, 2007

Hi All
im using sqlserver2005 and i have sqlquery to get some fileds
now  i need to get out put in excel file when i run sqlquery
can anyone explain me how can i do it...this is my query
select ta_targetpath from tblattributes where ta_pagelevel = 2 and ta_description like '%Do you want to watch this configuration in action%'
and ta_targetpath is not null
when i execute this i need to get result set in excel file...
thnx in advance
Hary

View 1 Replies View Related

Sqlquery Or Storedprocedure Error

Jun 18, 2008

Hello everyone,I am developing forums (Discussion Board) in C#.net 2005 with SqlServer. Right now i am having problem in fetching data from two tables.Here are the tables from which i want to fetch data.Topics Table                                  Threads TableTopicID                                          ThreadIDForumID                                        TopicIDTopicName                                    SubjectTopicDescription                            Replies                                                    UserID                                                    LastPostDatenow i want to fetch all the topic talbe data as well as total no of threads,Lastpostdate,UserID per topic.I am able to fetch  topic table data  and  Total no of  threads per topic through the following query.SELECT TopicID, ForumID, TopicName, TopicDescription,(SELECT COUNT(ThreadID)  FROM Portal_Threads WHERE (TopicID = Portal_Topics.TopicID)) AS Threads FROM Portal_Topicsbut i am not able to fetch anoter two detail with subquery as i am getting error likeonly one expression can be specified in the select listorsubquery returned more than one value.can anyone tell me how can i fetch these two values per topic. should i use stored procedure and create temporary table and after fetching these values i can store it in temporary table and i can fetch values from that temporary table...please provide code snippet if possible as i've never used sqlserver before..Thanks in advance...Regards,Nil 

View 8 Replies View Related

SQLquery Using Parameter Help Needed Please C#???

Aug 14, 2004

Hi All,

I'm trying to pass in a parameter value from an array in a loop that is used in a sql query and the results are populated to an xml file. The trouble is that I'm only getting the colums values in the outputted xml file. So I feel that the paramter is not being read.

So can anyone help as I'm really stuck on this one. The code is as follows :

public void DisplayUserInfo()
{

ArrayList UserIdArrayList = IdentifyUserID();
foreach(string ShowUserIDString in UserIdArrayList)
{
try
{
SqlConnection SqlConn = new SqlConnection(DBConnString);
SqlConn.Open();
Console.WriteLine("Connected to DB");
SqlDataAdapter SqlAD = new SqlDataAdapter();
SqlAD.SelectCommand = new SqlCommand("Select * from UserSystemSpecs where UserName ='+ShowUserIDString.ToString()+'",SqlConn);
DataSet ds = new DataSet();
SqlAD.Fill(ds);
ds.WriteXml(".\ResultsXML.xml", XmlWriteMode.WriteSchema);
}

catch (Exception ex)
{
throw new Exception ("Error Connecting to DB. " + ex.Message);
}
//SqlConn.Close();


}

}


Thanks

Garry

View 2 Replies View Related

Insert DEFAULT When Getting Values From A SQLquery

Nov 16, 2006

I have a this SP that inserts values into a table with results from a query, but at the same time I want to insert some default values.But thats NOT working the way I hoped for, actually sqlserver 2005 dont let me create this SP at all."Incorrect syntax near the keyword 'DEFAULT'."Can someone please tell me how I can achieve this? create procedure %PROC% ( @Ordre_ID int
)
asbeginIF NOT EXISTS(SELECT Ordre_ID FROM tbl_Ordre WHERE Ordre_ID = @Ordre_ID AND Ordrestatus IN ('2', '3', '4'))BEGIN return 0;ENDIF EXISTS(SELECT Ordre_ID FROM tbl_Faktura WHERE Ordre_ID = @Ordre_ID)BEGIN return 0; ENDBEGIN TRANSACTIONINSERT INTO tbl_Faktura( Ordre_ID ,PostNummer ,KID ,Fakturastatus ,Kontonummer ,Forfallsdato ,Belop ,BekreftetBetaltDato ,Faktura_GUID ,Adresse ,PostBoks ,Fornavn ,Etternavn ) (SELECT O.Ordre_ID ,K.PostNummer ,DEFAULT
,DEFAULT
,SI.Kontonummer
,(getdate()+14) ,v_OTS.TOTALBELOP ,DEFAULT
,DEFAULT
,K.Adresse
,K.PostBoks
,K.Fornavn
,K.Etternavn
FROM
tbl_Ordre AS O INNER JOIN
tbl_Kunde AS K ON
O.Kunde_ID = K.Kunde_ID
INNER JOIN
v_OrdreTotalSum AS v_OTS ON
O.Ordre_ID = v_OTS.Ordre_ID
,tbl_StatiskeInnstillinger AS SI WHERE
O.Ordre_ID = @Ordre_ID
)
UPDATE
tbl_Ordre
SET
Ordrestatus = '6'
WHERE Ordre_ID = @Ordre_ID COMMIT end
go
 

View 3 Replies View Related

Retrieving SQLQuery Results In Array On C#--How???

Apr 9, 2008

 Hi I'am practically new in C#, so I want to ask you guys some question.Let say I have this query:"Select EmployeeID, EmpName from PI_Employee"How can I retrieve the result from EmployeeID column and EmpName column and put it into collections of array, so I can call the array and use it again in another function. Can I possibly do that in C# ? if so, how ? please help me guys, I'm on the edge of nervous wreck in here so I could use a little help, any kinds of help. Thanks. Best Regards. 

View 9 Replies View Related

Retrieve SQLQuery Result In Array On C#--How ????

Apr 9, 2008

 Hi I'am practically new in C#, so I want to ask you guys some question.Let say I have this query:"Select EmployeeID, EmpName from PI_Employee"How can I retrieve the result from EmployeeID column and EmpName column and put it into collections of array, so I can call the array and use it again in another function. Can I possibly do that in C# ? if so, how ? please help me guys, I'm on the edge of nervous wreck in here so I could use a little help, any kinds of help. Thanks. Best Regards. 

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved