Showing posts with label value. Show all posts
Showing posts with label value. Show all posts

Friday, March 30, 2012

okay, I thought I had the return value from a statement figured out...

So, Jimmy G helped me out with it in showing a little bit how to do it.
SqlCommand command = new SqlCommand(, object>)SqlParameter param = new SqlParameter();param.ParameterName ="@.return";param.Direction = ParameterDirection.ReturnValue;command.Parameters.Add(param);command.ExecuteNonQuery();//get the return valueint val = int.Parse(command.Parameters[0].ToString());
 
 

Where I get lost is in the declaring of a new sqlcommand and sqlparameter. Can you please spell out where to use this and if I need to change my SQLdataSource. I currently was trying to use it in the OnClick of a button. What I had did the following

Protected Sub CreateIssue_Click(ByVal sender As Object, ByVal e As System.EventArgs)
dim returnValue as integer

'how do I get a return value from the stored procedure executed in 'insertissue.insert() here to a variable?

InsertIssue.Insert()

Response.Redirect("/addarticletoissue")


End Sub

again, thank you for your help and patience with such a beginner =)

I haven't seen your original post where jimmyg helped you out, so I am going to guess that you are trying to retrieve the autoincrement identity value of a newly added record from a SqlDataSource Try the approach detailed here:http://www.mikesdotnetting.com/Article.aspx?ArticleID=54 about 2/3rds of the way down.


|||

ahh! thank you so very much. This helps a ton!

Wednesday, March 7, 2012

ODBC SQL Server error

I have a ASP.Net application. I'm trying to access access data using SQL Server

my web config has

<addkey="connectionString"value="DRIVER={Sql Server};Server=(local);initial catalog=ymquizco_registration;User ID=sa;pwd=test"/>

MY CONNECTION STRING HAS THIS VALUE

"DRIVER={Sql Server};Server=localhost;initial catalog=ymquizco_registration;User ID=sa;pwd=test"

But the conn.Open();is throwing this error:

{"ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'WORK\\ASPNET'.\r\nERROR [01S00] [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute\r\nERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'WORK\\ASPNET'.\r\nERROR [01S00] [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute" }

My SQL Server is configured at mixed mode authentication. This seems like a install issue. Can someone think of something.

Fromhttp://www.connectionstrings.com, your connection string should look more like this:
Standard Security:

"Driver={SQL Server};Server=Aron1;Database=pubs;Uid=sa;Pwd=asdasd;"