|
That did the trick, thanks a million
|
|
|
|
|
You can't use a parameter for a field name...
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
The opposite of the religious fanatic is not the fanatical atheist but the gentle cynic who cares not whether there is a god or not.
Eric Hoffer
|
|
|
|
|
Hello all,
I am enhancing a DTS package developed by someone else. Main purpose of the DTS package is to import the data from the input excel sheets received from multiple customers.There are 7 data pump tasks to import from 7 customers' excel sheets. Each pump task is called in a loop in an ActiveX Script to be executed.
In ActiveX Script following logic is used to execute the pump task:
set stpraj = pkg.Steps("DTSStep_DTSDataPumpTask_2")
stpraj.ExecutionStatus = DTSStepExecStat_Waiting
I added a new data pump task to import the data from a new customer and I used the same logic as above:
set stpram = pkg.Steps("DTSStep_DTSDataPumpTask_8")
stpram.ExecutionStatus = DTSStepExecStat_Waiting
when I executed the package it gave execution errors. I replaced the code stpram.ExecutionStatus = DTSStepExecStat_Waiting
with
stpram.execute.
Now the package is executing properly and populating the data, but some of the things I did not understand are:
1. Why the package gave execution erroers when I used "stpram.ExecutionStatus = DTSStepExecStat_Waiting" ?
2. In the results after the execution of the package it showed the status for
"stpraj.ExecutionStatus = DTSStepExecStat_Waiting" as "COmplete" and for "stpram.execute" it showed "Running".
What is the difference between "stpraj.ExecutionStatus = DTSStepExecStat_Waiting" and "stpram.execute"? which one is preferable?.
Any information and suggestions on above doubts please!
Thanks in advance.
|
|
|
|
|
How do I bring up the ODBC Configuration dialog box and retrieve the paramters from VB . Net?
JRM
|
|
|
|
|
Hello Guys,
I am trying to connect to the remote SQL server on a machine named blrkec15710a. I want to do this using ODBC connection. But after writing my code i get the error
An unhandled exception of type 'System.TypeLoadException' occurred in System.Windows.Forms.dll
I am attaching my code below and making BOLD the line because of which the error creeps in. CODE IS AS FOLLOWS:-
_________________________________________________________________________
Imports Microsoft.data.odbc<br />
Imports System.Data<br />
Imports System.Data.SqlServerCe<br />
<br />
Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
Friend WithEvents txtDisplay As System.Windows.Forms.TextBox<br />
Friend WithEvents btnGET As System.Windows.Forms.Button<br />
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu<br />
<br />
[+] #Region " Windows Form Designer generated code "<br />
<br />
<br />
Private Sub btnGET_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGET.Click<br />
<br />
Try 'Driver={MsSQLSERVER};<br />
txtDisplay.Text = "Hello Zalak..."<br />
<br />
Dim strConnection As String = New String("DRIVER = {SQL Server};SERVER=blrkec15710A;UID=sa;PWD=SysAdmin;DATABASE=syncDS;")<br />
<br />
txtDisplay.Text = "after writing the connection string.."<br />
Dim SQL As String = New String("SELECT * FROM Orders")<br />
txtDisplay.Text = "after writing the SQL query"<br />
<br />
' Create connection object ---- PROBLEM IS HERE<br />
<br />
Dim conn As OdbcConnection = New OdbcConnection(strConnection) <br />
<br />
txtDisplay.Text = "create odbcConnection object.."<br />
<br />
Catch ex As Exception<br />
<br />
End Try<br />
<br />
End Sub<br />
End Class
_________________________________________________________________________
Now the error creeps in when i try to create an ODBCConnection object with the connection string as the parameter.
So most likely the error lies in the connection string.
My connection string:-
Dim strConnection As String = New String("DRIVER = {SQL Server};SERVER=blrkec15710A;UID=sa;PWD=SysAdmin;DATABASE=syncDS;")
here,
driver = SQL SERVER or should it be "'Microsoft SQL Server OBDC Driver Version 03.81.9042" that i see when i am trying to make the DSN and do TEST SOURCE that time i see this driver name in the summary.
server = blrkec15710a (my remote machine name where the SQL Server resides)
database = northwind or the name of the DSN made here "syncDS" which points to the Northwind database on server blrkec15710a
UID and PWD should they be in "" "" or as it is?
I need a solution to this immediately, whether the problem is with the connectionstring attributes or something else?
also where has the DSN to be made on the desktop where i am writing my application or the desktop where the SQL Server resides?
And when should the DRIVER attribute be blank, and if it blank then how does the connection string look like?
I will be really grateful to u people if i can get a response to this as soon as possible!!!
Thanks in advance,
Zalak dedhia
|
|
|
|
|
Create a DSN in the computer and use it as ODBC.
Al
|
|
|
|
|
I have the following problem when I output a select as XML. What happens, is that the query does not append line breaks to each record, so you are stuck with something that when you view in IE, it reports an error. This is because IE is just chopping the row to start it on the next line.
I will try explain it another way now. If there is a varchar(4000) buffer, what happens when the buffer is full, is that it adds that as a new row, then continues filling itself again. So what you end up with is records that get truncated by the viewing program (eg Internet Explorer)
|
|
|
|
|
hi
im using SqlDmo.dll to attach Database to MSDE and it gives me the following error msg
[microsoft][ODBC SQL Server Driver][SQL Server]The LSN(671:291:1)passed to log scan in database 'TelecontrollerPlus'is invalid
TelecontrollerPlus : is DB file name
and the code is
Dim SqlServ As New SQLDMO.SQLServer()
SqlServ.LoginSecure = True
SqlServ.Connect(SqlNAme)
OpenFileDialog1.ShowDialog()
Dim NAmes As String = OpenFileDialog1.FileName
If NAmes <> "" Then SqlServ.AttachDB("TelecontrollerPlus", "[" & NAmes & "]") : MsgBox("Attach DB is Done")
any one know aht is this error
thank u
|
|
|
|
|
from your database folder remove the .LDF (SQL server Database log file)
and then try to attach the database file to your server
At the end its all will be OK
|
|
|
|
|
HI all,
I have a table say table1 in which i have column1,column2,column3
I have a variable var1.
On the basis of value in var1 i wana fetch the data.
Like
if var1=1 then I wana select value from column1
if var1=2 then I wana select value from column2
can anyone please suggest the sqlserver2000 query for this.
thanks
|
|
|
|
|
|
As a college project we are making a database system, which we have planned to give to a school. we are using MySql server now. The question is this, is there a way to implement this project so that we wont have to install mysql server in the schools computer? we dont mind changing the database server or any thing for that matter. please help......
|
|
|
|
|
use ms access
|
|
|
|
|
I selected one Row from a Database and stored it in a DataTable. See code:
If ViewState("DataPeuter") Is Nothing Then
Dim sqlPConnection As SqlConnection
Dim sqlPDataAdaptor As SqlDataAdapter
Dim sqlPCommand As SqlCommand
Dim sqlPConnectionString As String
Dim sqlPSelectString As String
Try
sqlPConnectionString = "server=localhost;uid=sa;pwd=;database=KiddinSys"
sqlPSelectString = "Select * From Peuters Where Peuternummer = " & pNum
sqlPConnection = New SqlConnection(sqlPConnectionString)
sqlPCommand = New SqlCommand(sqlPSelectString, sqlPConnection)
sqlPDataAdaptor = New SqlDataAdapter(sqlPCommand)
dataTablePeuter = New DataTable
sqlPDataAdaptor.Fill(dataTablePeuter)
ViewState("DataPeuter") = dataTablePeuter
Catch exception As Exception
ErrorLabel.Text = exception.ToString()
End Try
Else
dataTablePeuter = CType(ViewState("DataPeuter"), DataTable)
End If
In the dataTablePeuter there is a Column named Geslacht as a Integer. What i would like to do is to convert this Integer to a String like this:
if dataTablePeuter.Geslacht = 1 Then
lblGeslacht.Text = "Jongen"
ElseIf dataTablePeuter.Geslacht = 2 Then
lblGeslacht.Text = "Meisje"
Else
lblGeslacht.Text = "Onbekend"
EndIf
The question is what is the correct syntaxs for if dataTablePeuter.Geslacht = 1 Then
|
|
|
|
|
Hello,
I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine.
The update is not. I checked and my database has all the necessary records in it when testing it. I get the error "No value given for one or more required parameters." when I try to update the database.
Can you tell me what am I doing wrong?
Thanks,
Miguel
These are my 3 codes:
UPDATE
' Set Connection
Dim connectionString As String = AppSettings("connectionString")
Dim dbConnection As IDbConnection = New OleDbConnection(connectionString)
' Set Query and Command
Dim queryString As String = "UPDATE [t_news] SET [news_id]=@news_id, [title_pt-PT]=@title_pt-PT, [title_en-GB]=@title_en-GB, [text_pt-PT]=@text_pt-PT, [text_en-GB]=@text_en-GB, [publication_date]=@publication_date WHERE ([t_news].[news_id] = @news_id)"
Dim dbCommand As IDbCommand = New OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
' Add Parameters
With dbCommand.Parameters
.Add(New OleDbParameter("@news_id", 1))
.Add(New OleDbParameter("@title_pt-PT", "Test UPDATE - title PT"))
.Add(New OleDbParameter("@title_en-GB", "Test UPDATE - title EN"))
.Add(New OleDbParameter("@text_pt-PT", "Test UPDATE - text PT"))
.Add(New OleDbParameter("@text_en-GB", "Test UPDATE - text EN"))
.Add(New OleDbParameter("@publication_date", DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss")))
End With
' Update Record
dbConnection.Open()
Try
dbCommand.ExecuteNonQuery()
Finally
dbConnection.Close()
End Try
INSERT
' Set Connection
Dim connectionString As String = AppSettings("connectionString")
Dim dbConnection As IDbConnection = New OleDbConnection(connectionString)
' Set Query and Command
Dim queryString As String = "INSERT INTO [t_news] ([title_pt-PT], [title_en-GB], [text_pt-PT], [text_en-GB], [publication_date]) VALUES (@title_ptPT, @title_enGB, @text_ptPT, @text_enGB, @publication_date)"
Dim dbCommand As IDbCommand = New OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
' Add Parameters
With dbCommand.Parameters
.Add(New OleDbParameter("@title_ptPT", "Test INSERT - title PT"))
.Add(New OleDbParameter("@title_enGB", "Test INSERT - title EN"))
.Add(New OleDbParameter("@text_ptPT", "Test INSERT - text PT"))
.Add(New OleDbParameter("@text_enGB", "Test INSERT - text EN"))
.Add(New OleDbParameter("@publication_date", DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss")))
End With
' Insert New Record
dbConnection.Open()
Try
dbCommand.ExecuteNonQuery()
Finally
dbConnection.Close()
End Try
DELETE
' Set Connection
Dim connectionString As String = AppSettings("connectionString")
Dim dbConnection As IDbConnection = New OleDbConnection(connectionString)
' Set Query and Command
Dim queryString As String = "DELETE FROM [t_news] WHERE ([t_news].[news_id] = @news_id)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
' Add Parameters
dbCommand.Parameters.Add(New OleDbParameter("@news_id", 2))
' Delete Record
dbConnection.Open()
Try
dbCommand.ExecuteNonQuery()
Finally
dbConnection.Close()
End Try
|
|
|
|
|
I believe oledb parameters are 'placement' only parameters (that is, the name of the parameter is irrelevant, only its order in the statement matters) In this case you have one more parameter (placement wise) in the statement than you are adding to the parameter collection (you can't get away with 'sharing' the news_id parameter just by name matching, you must add another parameter using the same value, but a different name - the names must be unique to satisfy the collection rules, but serve no role in terms of matching parameters in the statement). I suspect you dont really want to CHANGE the value of news_id anyway, so just remove it from your filed list, and move the parameter to last in the colection.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
The opposite of the religious fanatic is not the fanatical atheist but the gentle cynic who cares not whether there is a god or not.
Eric Hoffer
|
|
|
|
|
Hi,
I did that:
' Set Query and Command
Dim queryString As String = "UPDATE [t_news] SET [news_id]=@news_id_update, [title_pt-PT]=@title_ptPT, [title_en-GB]=@title_enGB, [text_pt-PT]=@text_ptPT, [text_en-GB]=@text_enGB, [publication_date]=@publication_date WHERE ([t_news].[news_id] = @news_id)"
...
' Add Parameters
With dbCommand.Parameters
.Add(New OleDbParameter("@news_id_update", 5))
.Add(New OleDbParameter("@news_id", 5))
.Add(New OleDbParameter("@title_ptPT", "Test UPDATE - title PT"))
.Add(New OleDbParameter("@title_enGB", "Test UPDATE - title EN"))
.Add(New OleDbParameter("@text_ptPT", "Test UPDATE - text PT"))
.Add(New OleDbParameter("@text_enGB", "Test UPDATE - text EN"))
.Add(New OleDbParameter("@publication_date", DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss")))
End With
I get the error: "Cannot update 'news_id'; field not updateable."
Remember that news_id is the primary key on my Access database and set as "AutoNumber"
Then I tried the following query as i don't need to change the news_id field:
Dim queryString As String = "UPDATE [t_news] SET [title_pt-PT]=@title_ptPT, [title_en-GB]=@title_enGB, [text_pt-PT]=@text_ptPT, [text_en-GB]=@text_enGB, [publication_date]=@publication_date WHERE ([t_news].[news_id] = @news_id)"
I don't get any error but there is no change in data!!!! And record 5 is there!
I even placed a Response.Write("Done") in the code:
' Update Record
dbConnection.Open()
Try
dbCommand.ExecuteNonQuery()
Finally
dbConnection.Close()
Response.Write("Done")
End Try
And it is displayed "DONE"!
My INSERT and DELETE codes are working fine.
What is going on with this UPDATE code?
Thanks,
Miguel
|
|
|
|
|
You missed my most important point. The parameters are PLACEMENT (i.e. ORDER) sensitive. You must add the parameters to the collection in the same order that you used them in the statement. You get no update because no news_id value in the table matches the publication date (politly converted to a long integer). news_id MUST be the last parameter added to the collection. To be sure that the ADD method overload is not doing some polite conversion behind your back, you should specify the data type and direction for the parameters, as well, rather than rely on the parameter constructor to determine them for you.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
The opposite of the religious fanatic is not the fanatical atheist but the gentle cynic who cares not whether there is a god or not.
Eric Hoffer
|
|
|
|
|
Instead of the lines:
..." .Add(New OleDbParameter("@title_ptPT", "Test INSERT - title PT"))"
try to use:
".Add("@title_ptPT", "Test INSERT - title PT")
As far as I know there is no need to declare a new OleDbParameter in this statement.
Hope it helps.
JJRDK
|
|
|
|
|
As Rob answered, the parameters are order-sensitive for OleDb * classes. So add the @news-id parameter again at the end, since you reference it at the end.
I just answered this more throughly on the ASP.NET forum, so please don't cross-post in different forums, it's considered bad manners here.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hiya all.
I really hope you guys can help me with this question/problem.
First off - sorry for the lenght of the post.
I have a productstructure which I'm trying to read out via SQL, using User Defined Functions.
Setting:
Basically - my structure in the database consists of product groups and products. A product can be sub-group to the parent, and have products connected.
So I have a Group A, which is a parent to Group A-1 which contains the product A-1p1, A-1p2 etc. (simplified, I think currently there is only 7 parent groups, which have a number of subgroups, which have yet another bunch of subgroups which have products connected them)
I use a function which returns a table of groups, given the parents id, so parent id = 0 will return all the root elements.
I also have a function which returns a table of products given the group id.
Then I have created this recursive function:
<small>CREATE FUNCTION fnGroupListByParentRecusive<br />
(<br />
@CurrentGroupID int,<br />
@NodePath nvarchar(2000),<br />
@LanguageCode nvarchar(5)<br />
)<br />
RETURNS @ProductStruct TABLE(NodePath nvarchar(2000), PROD_GroupID int, PROD_GroupName nvarchar(200), PROD_ProductID int, PROD_ProductName nvarchar(200))<br />
AS <br />
BEGIN <br />
<br />
-- DECLARE LOCAL VARIABLES --<br />
DECLARE @GroupID INT<br />
DECLARE @Group TABLE(PROD_GroupID int, PROD_GroupName nvarchar(200))<br />
DECLARE @Product TABLE(PROD_ProductID int, PROD_ProductName nvarchar(200), PROD_GroupID int)<br />
DECLARE @InternalNodePath nvarchar(2000)<br />
<br />
-- Get product group data<br />
INSERT @Group SELECT PROD_GroupID, PROD_GroupName FROM fnGroupListByParentID(@CurrentGroupID, @LanguageCode)<br />
<br />
-- DECLARE CURSOR --<br />
DECLARE myCursor CURSOR<br />
FOR <br />
SELECT PROD_GroupID FROM @Group<br />
OPEN myCursor<br />
<br />
FETCH NEXT FROM myCursor INTO @GroupID<br />
WHILE (@@FETCH_STATUS <> -1 AND @@FETCH_STATUS <> -2) BEGIN<br />
-- Get Product data<br />
INSERT @Product SELECT PROD_ProductID, PROD_ProductName, PROD_GroupID FROM fnProductListByGroupID(@GroupID,@LanguageCode)<br />
<br />
-- Set path <br />
SET @InternalNodePath = @NodePath + '/' + LTRIM((str(@GroupID)))<br />
<br />
-- Build ProductStructure Table<br />
INSERT @ProductStruct <br />
SELECT @InternalNodePath, T1.PROD_GroupID, T1.PROD_GroupName, T2.PROD_ProductID, T2.PROD_ProductName<br />
FROM @Group AS T1 LEFT JOIN @Product AS T2<br />
ON T1.PROD_GroupID = T2.PROD_GroupID <br />
<br />
-- Build ProductStructure table with Recursive data.<br />
INSERT @ProductStruct SELECT * FROM dbo.fnGroupListByParentRecusive(@GroupID, @InternalNodePath, @LanguageCode)<br />
<br />
-- Get Next cursor<br />
FETCH NEXT FROM myCursor INTO @GroupID<br />
END<br />
CLOSE myCursor<br />
DEALLOCATE myCursor<br />
RETURN<br />
END</small>
My problem is that this works somewhat.
I apparently get the results from the tables repeated a number of times. The way I figured this out was by view in the NodePath.
This path is the nodes to get the to current, inclusive the current nodes group id.
For instance - the 7 root elements would get the path 0/groupid, and these elements children would get 0/groupid/groupid2 etc.
However - say my Groups have IDs 1, 2, 3 I get the result
<br />
Path GroupID<br />
0/1 1<br />
0/1 2<br />
0/1 3<br />
0/2 1<br />
0/2 2<br />
0/2 3<br />
0/3 1<br />
0/3 2<br />
0/3 3<br />
Which is not what I wanted.
I wanted
<br />
0/1 1<br />
0/2 2<br />
0/3 3<br />
Now my question and problem is that I want to get from the first list to the second list.
I have an idea that the problem would be that some variables in my function are of global scope as opposed to what I'd expect from for instance a programming language, so each time I run
-snip-<br />
INSERT @ProductStruct <br />
SELECT @InternalNodePath, T1.PROD_GroupID, T1.PROD_GroupName, T2.PROD_ProductID, T2.PROD_ProductName<br />
FROM @Group AS T1 LEFT JOIN @Product AS T2<br />
ON T1.PROD_GroupID = T2.PROD_GroupID <br />
<br />
-- Build ProductStructure table with Recursive data.<br />
INSERT @ProductStruct SELECT * FROM dbo.fnGroupListByParentRecusive(@GroupID, @InternalNodePath, @LanguageCode)<br />
-snip-<br />
then it updates the same table, instead of using a function scoped table which it returns through my recursive call.
However - until today I've never even used userdefined functions, so my knowlegde of this area is very limited (I'm surprised I've gotten this far).
Can anybody help point me in the proper direction and possible tell me if my fear of scope is correct?
With regards and hopes.
Alsvha
---------------------------
127.0.0.1 - Sweet 127.0.0.1
|
|
|
|
|
Hallo,
I've opened a file from my oracle database via a OracleBlob format into a byte array and it works all very well, except that I would like it not to be saved on the c: drive
How can I do this ?
here is my code :
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//roep functie docDownloadBlob aan en lees document in.
//Response.Clear();
DataSet ds = new DataSet();
Attachements oAttachement = new Attachements();
//Geeft ds terug
oAttachement.USER_ID = int.Parse(Session["userid"].ToString());
oAttachement.DOC_ID = int.Parse(Request.QueryString["DOC_ID"].ToString());
string m = oAttachement.GetBlob();
byte[] MyData = new byte[0];
if (m == "OK")
{
MyData = oAttachement.ByteData;
}
int ArraySize = new int();
ArraySize = MyData.GetUpperBound(0);
String DestinationLoc = "C:/ViewFiles.txt" ;
System.IO.FileStream fs = new System.IO.FileStream(@DestinationLoc, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
System.IO.FileStream fs = new System.IO.FileStream(@DestinationLoc, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Read);
fs.Write(MyData, 0, ArraySize);
StreamWriter sw = new StreamWriter(fs);
Response.AddHeader("Content-disposition", "attachment;filename=ViewFiles.txt");
Response.AddHeader("Content-Length", DestinationLoc.Length.ToString());
Response.ContentType = "application/txt";
Response.BinaryWrite(MyData);
fs.Close();
Can anyone help me with this please ?
tnx.
Cara
|
|
|
|
|
You may write the file to disk, but you don't do anything else with it. If you don't want it written to disk then just remove that code. Also, by writing the file to the disk in this way (especially to the root of your C drive) you've had to blow open a hole in the security of your application to allow it to write there.
You are also writing the bytes out to the Responce oject. In the past, I've just overloaded the Render method to do this work. It is much easier and, if I remember correctly, it passes you a HttpStream to write into.
By the way, you might get a better response to your question in the ASP.NET forum. Your question has little to do with ADO.NET (even although the data you are writing initially comes from a data source, your question relates to getting that data across to a browser)
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
OK tnx for the answer anyway. i'll keep in mind next time to stick to the point of ado.
|
|
|
|
|
I have a program I'm working with (VB ) which accesses it's data via ODBC and an Access database. The Access database is currently in 97 format because I had certain strange problems when it was in Access 2002 format, namely updating records and then finding it had written blank fields to the database etc. These problems disappeared with a Access 97 file.
I've recently tried to let this program talk to a SQL server via ODBC which works perfectly, except that it displays the same anomalies as Access databases newer than 97. My suspicion is that the ODBC driver is outdated. Does anyone know if that is possibly the problem, and if so how I can update it. If not, what can it be?
TIA
Paul
modified 18-Jul-18 11:59am.
|
|
|
|
|